True循环脚本停止运行时,不会终止或引发错误

时间:2019-06-21 21:51:03

标签: python loops while-loop python-requests python-requests-html

从循环运行此代码开始,它不会终止还是似乎结束?没有错误被捕获/抛出。一旦在输出控制台上的第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行之后停止运行?

0 个答案:

没有答案