如何减少逾期要求?

时间:2019-07-10 11:02:29

标签: python python-3.x beautifulsoup python-requests python-requests-html

我为每个网站的主题分配了30个请求。对于某些人来说,15-20个请求是徒劳的。我该如何减少呢?

我正在使用Python BeautifulSoup库从站点中提取数据。

The architecture of the site is as follows ( each topic ):
      www.abc.com/
      www.abc.com/1
      www.abc.com/2
      www.abc.com/3
      www.abc.com/4
      www.abc.com/5
      www.abc.com/6
for firstTemplate in firstTemplates:
      i=1
      while i < 30:
          sendRequest = requests.get(firstTemplate + str(i))
          source = BeautifulSoup(sendRequest.content, "lxml")
          i = i + 1

当我查看该网站的所有问题时,平均/数量是25-26。但并非所有线程都相同,因此我将分配30个固定请求。例如:30次请求后www.abc.com/5。我抛出25要求什么。我是否应该编写类似“将相同数据从循环中拉出”的内容?我认为这将改善程序的性能。但是我不知道如何。

0 个答案:

没有答案