[F] Fix while loop logic

This commit is contained in:
Azalea Gui
2023-02-07 23:27:50 -05:00
parent b4c0f8d259
commit 5d54afe8fe
+12 -10
View File
@@ -93,17 +93,19 @@ def crawl(item_url: str) -> dict:
id = get_url_param(item_url, 'id')
out_path = Path(f'crawler/{id}.json')
if out_path.is_file():
return json.loads(out_path.read_text())
while True:
if not out_path.is_file():
print(f'Crawling {id}...')
out_path.parent.mkdir(parents=True, exist_ok=True)
resp = r.post('https://front.superbuy.com/crawler/', data={"needSoldOutSkuInfo": 1, "location": 2, "goodUrl": item_url})
if resp.status_code != 200:
print(f"Request failed: {resp.status_code}")
assert input("Retry? [y/N]").lower() == 'y'
continue
out_path.write_text(resp.text)
return resp.json()
print(f'Crawling {id}...')
out_path.parent.mkdir(parents=True, exist_ok=True)
resp = r.post('https://front.superbuy.com/crawler/', data={"needSoldOutSkuInfo": 1, "location": 2, "goodUrl": item_url})
if resp.status_code != 200:
print(f"Request failed: {resp.status_code}")
assert input("Retry? [y/N]").lower() == 'y'
continue
out_path.write_text(resp.text)
return resp.json()
def create_diy_order(create: list[TaobaoOrder]):