-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8c54ad
commit 21ed442
Showing
11 changed files
with
69 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
import requests | ||
import cloudscraper | ||
from ..search import log | ||
|
||
|
||
def get_html(url, proxies=None, system_proxy=False, verify=True): | ||
if system_proxy: | ||
http_proxy = os.environ.get('http_proxy') | ||
https_proxy = os.environ.get('https_proxy') | ||
if http_proxy or https_proxy: | ||
proxies = {'http': http_proxy, 'https': https_proxy} | ||
else: | ||
log.warning("No system proxy found.") | ||
raise requests.exceptions.ProxyError("No system proxy found.") | ||
|
||
try: | ||
if not verify: | ||
requests.packages.urllib3.disable_warnings() | ||
|
||
scraper = cloudscraper.create_scraper(delay=5, browser={ | ||
'browser': 'chrome', | ||
'platform': 'linux', | ||
'mobile': False, | ||
}) | ||
|
||
response = scraper.get(url, proxies=proxies, verify=verify) | ||
|
||
log.debug(f"A request has been made to url: {url}") | ||
return response.content | ||
|
||
except requests.RequestException as e: | ||
log.exception(f"The search was aborted due to network reasons: {e}") | ||
raise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters