网页抓取脚本挂起

2024-04-19 14:46:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个重要的网页抓取脚本:

repeats over all website names:
    retrieves image off of website
    adds to dictionary with key as website name
    prints out what number of the list its on (for tracking purposes)

但是,处理循环的每次迭代通常需要3秒左右。但是每75轮左右,它会在某个特定的迭代中突然停止并挂起大约10分钟,然后继续。这真的很烦人,否则脚本只需要一个小时。每当出现挂起时,我注意到终端标题看起来像:

enter image description here

当它正常运行时,它看起来像:

enter image description here

旁边有一个圆形的跑步机。我的猜测是,这只是因为它在连接网站时遇到了问题。虽然我的网速很快。此外,所有图像的大小都差不多。有人知道为什么它会时不时地挂起来吗?在


Tags: oftoimage脚本网页dictionarynameswith