【问题标题】:BeautifulSoup only returning first page on crawling listBeautifulSoup 只返回爬行列表的第一页
【发布时间】:2022-01-18 03:30:06
【问题描述】:

我有一个 url 列表,我试图让漂亮的汤通过爬网,但它只捕获第一页数据。很确定这只是我的循环设置方式的问题,但任何帮助表示赞赏

   scripts_raw = []
   for link in random_urls:
       r = requests.get(random_urls)
       r.encoding = 'utf-8'
       tml_content = r.text
       soup = BeautifulSoup(r.content, "html.parser")

       script = soup.find('td', class_='scrtext')
       scripts_raw.append(script)

【问题讨论】:

  • 你的意思是 ``` r = requests.get(link)``` 吗?你没有在任何地方使用link

标签: python loops web-scraping beautifulsoup


【解决方案1】:

你的循环没有使用链接,试试这样: r = requests.get(链接)

【讨论】:

  • 请使用add comment 部分回复讨论、疑问。
  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 1970-01-01
  • 2022-08-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-14
相关资源
最近更新 更多