Skip to content

Commit 9d42f9a

Browse files
authored
Merge pull request #12 from opsdisk/minor-cleanup-20220730
Updated formatting, fixed typos
2 parents ab59ec3 + ee8d1fb commit 9d42f9a

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

yagooglesearch/__init__.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# Custom Python libraries.
1414

15-
__version__ = "1.6.0"
15+
__version__ = "1.6.1"
1616

1717
# Logging
1818
ROOT_LOGGER = logging.getLogger("yagooglesearch")
@@ -32,8 +32,8 @@
3232
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
3333

3434
# Load the list of valid user agents from the install folder. The search order is:
35-
# 1) user_agents.txt
36-
# 2) default USER_AGENT
35+
# 1) user_agents.txt
36+
# 2) default USER_AGENT
3737
install_folder = os.path.abspath(os.path.split(__file__)[0])
3838

3939
try:
@@ -155,7 +155,16 @@ def __init__(
155155
self.cookies = None
156156

157157
# Used later to ensure there are not any URL parameter collisions.
158-
self.url_parameters = ("btnG", "cr", "hl", "num", "q", "safe", "start", "tbs")
158+
self.url_parameters = (
159+
"btnG",
160+
"cr",
161+
"hl",
162+
"num",
163+
"q",
164+
"safe",
165+
"start",
166+
"tbs",
167+
)
159168

160169
# Default user agent, unless instructed by the user to change it.
161170
if not user_agent:
@@ -272,7 +281,7 @@ def filter_search_result_urls(self, link):
272281
)
273282
link = None
274283

275-
# TODO: Generates false positives if specifing an actual Google site, e.g. "site:google.com fiber".
284+
# TODO: Generates false positives if specifying an actual Google site, e.g. "site:google.com fiber".
276285
if urlparse_object.netloc and ("google" in urlparse_object.netloc.lower()):
277286
ROOT_LOGGER.debug(f'Excluding URL because it contains "google": {link}')
278287
link = None
@@ -338,15 +347,15 @@ def get_page(self, url):
338347
"vary, but I'll try and work around this by updating the cookie."
339348
)
340349

341-
# Convert the cookiejar data struture to a Python dict.
350+
# Convert the cookiejar data structure to a Python dict.
342351
cookie_dict = requests.utils.dict_from_cookiejar(self.cookies)
343352

344353
# Pull out the random number assigned to the response cookie.
345354
number = cookie_dict["CONSENT"].split("+")[1]
346355

347356
# See https://github.com/benbusby/whoogle-search/pull/320/files
348357
"""
349-
Attempting to disect/breakdown the new cookie response values.
358+
Attempting to dissect/breakdown the new cookie response values.
350359
351360
YES - Accept consent
352361
shp - ?
@@ -416,7 +425,7 @@ def search(self):
416425
if builtin_param in self.extra_params.keys():
417426
raise ValueError(f'GET parameter "{builtin_param}" is overlapping with the built-in GET parameter')
418427

419-
# Simulates browsing to the google.com home page and retrieving the initial cookie.
428+
# Simulates browsing to the https://www.google.com home page and retrieving the initial cookie.
420429
html = self.get_page(self.url_home)
421430

422431
# Loop until we reach the maximum result results found or there are no more search results found to reach
@@ -533,7 +542,7 @@ def search(self):
533542
else:
534543
ROOT_LOGGER.info(f"Duplicate URL found: {link}")
535544

536-
# If we reached the limit of requested URLS, return with the results.
545+
# If we reached the limit of requested URLs, return with the results.
537546
if self.max_search_result_urls_to_return <= len(self.search_result_list):
538547
return self.search_result_list
539548

0 commit comments

Comments
 (0)