bugfix
This commit is contained in:
@@ -8,6 +8,7 @@ from random import randint
|
||||
import time
|
||||
import json
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
def crawl_links(side, data):
|
||||
options = Options()
|
||||
@@ -32,6 +33,7 @@ def crawl_links(side, data):
|
||||
|
||||
break
|
||||
except NoSuchElementException as nsee:
|
||||
traceback.print_exc()
|
||||
breakup_counter = breakup_counter + 1
|
||||
if breakup_counter == 150:
|
||||
raise Exception
|
||||
@@ -44,6 +46,7 @@ def crawl_links(side, data):
|
||||
|
||||
time.sleep(3)
|
||||
except NoSuchElementException as nsee:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
|
||||
if side["search"] == "True":
|
||||
@@ -70,6 +73,7 @@ def crawl_links(side, data):
|
||||
links.append(link)
|
||||
|
||||
except NoSuchElementException as nsee:
|
||||
traceback.print_exc()
|
||||
break
|
||||
|
||||
time.sleep(randint(1, 5))
|
||||
@@ -89,27 +93,33 @@ def crawl_links(side, data):
|
||||
|
||||
break
|
||||
except NoSuchElementException as nsee:
|
||||
traceback.print_exc()
|
||||
breakup_counter = breakup_counter + 1
|
||||
if breakup_counter == 150:
|
||||
raise Exception
|
||||
time.sleep(3)
|
||||
|
||||
except WebDriverException as wde:
|
||||
traceback.print_exc()
|
||||
break
|
||||
|
||||
if side["page_selector"] == "True":
|
||||
selector = driver.find_element(By.XPATH, side["selector"].replace("'", '"'))
|
||||
all_options = selector.find_elements(By.TAG_NAME, "option")
|
||||
try:
|
||||
selector = driver.find_element(By.XPATH, side["selector"].replace("'", '"'))
|
||||
all_options = selector.find_elements(By.TAG_NAME, "option")
|
||||
|
||||
if selector_counter == len(all_options):
|
||||
if selector_counter == len(all_options):
|
||||
break
|
||||
|
||||
next_value = all_options[selector_counter].get_attribute("value")
|
||||
selector_counter += 1
|
||||
|
||||
|
||||
Select(selector).select_by_value(next_value)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
break
|
||||
|
||||
next_value = all_options[selector_counter].get_attribute("value")
|
||||
selector_counter += 1
|
||||
|
||||
|
||||
Select(selector).select_by_value(next_value)
|
||||
|
||||
time.sleep(randint(1, 5))
|
||||
|
||||
# close driver
|
||||
@@ -144,7 +154,8 @@ if __name__ == '__main__':
|
||||
print(f"Getting links from {name}.")
|
||||
try:
|
||||
crawl_links(side, data)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
print(f"Error while getting {name}-links. Check links_config.json!")
|
||||
|
||||
print("Writing links.")
|
||||
|
||||
Reference in New Issue
Block a user