Skip to content

Commit

Permalink
Update scraper.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandhunt committed Jan 27, 2020
1 parent f667fa8 commit 39a3e4e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions scraper.py
Expand Up @@ -228,14 +228,13 @@ def doeshtmlelementexist(selectedel):
nextURLs = ''
try:
optionals = Options()
if scrapsite['scrapefield']['phantomjsimport'] != 'phantomjsimport_pagenumber' and\
scrapsite['scrapefield']['phantomjsimport'] != 'phantomjsimport_default':
if scrapsite['scrapefield']['phantomjsimport'] != 'phantomjsimport_pagenumber' and scrapsite['scrapefield']['phantomjsimport'] != 'phantomjsimport_default':
optionals.add_argument('--user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0"')
optionals.add_argument('--disable-dev-shm-usage')
optionals.add_argument('--disable-extensions')
optionals.add_argument('--no-sandbox')
optionals.add_experimental_option('prefs', {'intl.accept_languages': 'sv',\
'profile.default_content_setting_values.geolocation': 1,\
optionals.add_experimental_option('prefs', {'intl.accept_languages': 'sv',
'profile.default_content_setting_values.geolocation': 1,
'profile.default_content_settings.geolocation': 1})
with Browser('chrome', headless=True, options=optionals) as browser:
browser.driver.set_page_load_timeout(300)
Expand All @@ -245,8 +244,7 @@ def doeshtmlelementexist(selectedel):
"accuracy": 100}
response = browser.driver.execute_cdp_cmd("Page.setGeolocationOverride", params)
try:
if scrapsite['scrapefield']['phantomjsimport'] == 'phantomjsimport_pagenumber' or\
scrapsite['scrapefield']['phantomjsimport'] == 'phantomjsimport_default':
if scrapsite['scrapefield']['phantomjsimport'] == 'phantomjsimport_pagenumber' or scrapsite['scrapefield']['phantomjsimport'] == 'phantomjsimport_default':
browser.visit(product['scrapeurl'])
time.sleep(2)
html_source = browser.html
Expand Down

0 comments on commit 39a3e4e

Please sign in to comment.