python api接口10060_Python请求错误10060

我有一个脚本爬行一个网站。

直到今天一切都很完美,

但是现在它没有这样做。

它会给sme以下错误:Connection Aborted Error(10060 ' A connection attempt failed becvause the connected party did not properly respond after a period of time, or established a connection failed because connected host has failed to respond'

我一直在寻找答案和设置,但我不知道如何解决这个。。。

在IE中,我不使用任何代理(连接->Lan设置->代理=禁用)

它在这段代码中被破坏了,有的是第一次运行,有的是第二次运行。。等等def geturls(functionurl, runtime):

startCrawl = requests.get(functionurl, headers=headers)

mainHtml = BeautifulSoup(startCrawl.content, 'html.parser')

mainItems = mainHtml.find("div",{"id": "js_multiselect_results"})

for tag in mainItems.findAll('a', href=True):

tag['href'] = urlparse.urljoin(url,tag['href'])

if shorturl in tag['href'] and tag['href'] not in visited:

if any(x in tag['href'] for x in keepout):

falseurls.append(tag['href'])

elif tag['href'] in urls:

doubleurls.append(tag['href'])

else:

urlfile.write(tag['href'] + "\n")

urls.append(tag['href'])

totalItemsStart = str(mainHtml.find("span",{"id": "sab_header_results_size"}))

if runtime == 1:

totalnumberofitems[0] = totalItemsStart

totalnumberofitems[0] = strip_tags(totalnumberofitems[0])

return totalnumberofitems

我该怎么解决?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值