-
Notifications
You must be signed in to change notification settings - Fork 501
Expand file tree
/
Copy pathquery_script.py
More file actions
28 lines (21 loc) · 834 Bytes
/
query_script.py
File metadata and controls
28 lines (21 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""A Python script that produces Google rankwise links related to a particular query"""
from googlesearch import search
def google_search_results(keyword, domain="com"):
"""
:param keyword: Provided with string type data for which links are produced
:param domain: Provided with string type data to which resultant links are associated
"""
for links in search(keyword, tld=domain, pause=2):
yield links
def main():
query = input("Enter your search keyword: ")
number_of_results = int(input("Enter number of links you want: "))
count = 1
for link in google_search_results(query):
# final result is printed in the form [rank link]
if count > number_of_results:
break
print(count, link, "\n")
count += 1
if __name__ == "__main__":
main()