Skip to content

Commit

Permalink
Add dynamic for both http and https proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammed-Ashour committed Apr 20, 2021
1 parent 08ab8b0 commit 2bc0efe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions googlesearch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ def fetch_results(search_term, number_results, language_code):

google_url = 'https://www.google.com/search?q={}&num={}&hl={}'.format(escaped_search_term, number_results+1,
language_code)
proxies = {"https":proxy} if proxy else None
response = get(google_url, headers=usr_agent, proxies=proxies)
proxies = None
if proxy:
if proxy[:5]=="https":
proxies = {"https":proxy}
else:
proxies = {"http":proxy}

response = get(google_url, headers=usr_agent, proxies=proxies)
response.raise_for_status()

return response.text
Expand Down

0 comments on commit 2bc0efe

Please sign in to comment.