forked from dray89/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogle.py
More file actions
21 lines (20 loc) · 694 Bytes
/
google.py
File metadata and controls
21 lines (20 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#use googlesearch or similar package but ensure use of request package - not urllib -
import csv, bs4
terms = []
with open("list.csv", "r") as file:
read = csv.reader(file, delimiter= ' ', quotechar = '|')
for row in read:
terms.append(row)
output = []
res = str("website")
restrict = [res]
for each in terms:
from googlesearch import search
for url in search(query=each, stop=3, domains=restrict):
print(str(url))
output.append(str(url))
with open("output.csv", "w", newline="") as myfile:
outputfile = csv.writer(myfile)
for url in output:
outputfile.writerow(url)
myfile.close()