从循环运行此代码,它不会终止或似乎结束?没有捕获/抛出错误。一旦它位于输出控制台的第 189 行,它总是会执行此操作。
import time
from requests_html import HTMLSession
product_urls = ["https://footdistrict.com/en/adidas-yeezy-boost-700-ee9614.html", "https://footdistrict.com/en/adidas-yeezy-boost-350-v2-static-ef2905.html"]
session = HTMLSession()
def monitor():
try:
for url in product_urls:
print("Searching for url: {} ...\n".format(url))
r = session.get(url,timeout=20)
r.html.render()
search = r.html.find(("#attribute134"), first =True)
if search is not None:
print("Item is in stock.")
else:
print("Item is out of stock.")
except Exception as e:
print(e)
time.sleep(3)
while True:
monitor()
是不是某种内存错误导致了这种情况?我试图增加到time.sleep(3)
类似的东西,time.sleep(30)
但这没有任何区别,在控制台的第 189 行之后仍然停止运行?