handle items not found
This commit is contained in:
parent
afdaa49f19
commit
0cfe551ce5
@ -42,6 +42,7 @@ def check_item(settings_item):
|
||||
itemid is in aliexpress link to item page. attributes is a list of string. Each string is a choice value (for example which length, or which colour) if multiple items are on the same page, only one by category, order doesn't matter.
|
||||
'''
|
||||
punish_regex = re.compile(r'(pid: \'punish-page\')|(Deny from x5)|(FAIL_SYS_ILLEGAL_ACCESS)')
|
||||
not_found_regex = re.compile(r'(Sorry, the page you requested can not be found)|(https://ae01.alicdn.com/kf/S01523ef93482448d8c33d410344d6a9eI/361x360.png)')
|
||||
number_regex = re.compile(r'[0-9]+')
|
||||
price_regex = re.compile(r'[0-9]*,[0-9]{0,2}')
|
||||
|
||||
@ -99,10 +100,17 @@ def check_item(settings_item):
|
||||
|
||||
# check if punish page hit
|
||||
punish = bool(re.search(punish_regex, driver.page_source))
|
||||
# check if the item exists
|
||||
not_found = bool(re.search(punish_regex, driver.page_source))
|
||||
|
||||
|
||||
if punish:
|
||||
print("punish page")
|
||||
driver.quit()
|
||||
raise ValueError("punish")
|
||||
elif not_found:
|
||||
print("item not found")
|
||||
return {}
|
||||
else:
|
||||
# refresh page to have the price in a single span
|
||||
driver.refresh()
|
||||
|
Loading…
x
Reference in New Issue
Block a user