我有一个简单的 for 循环,它运行但打印每个链接 3 次。为什么?(页面共有 3 个“事件”)
我试图从中抓取的网站 = https://www.aacr.org/get-involved/events/
这是代码->
import requests
from bs4 import BeautifulSoup
import pandas as pd
productlinks = []
url='https://www.aacr.org/get-involved/events/'
r=requests.get(url)
soup=BeautifulSoup(r.content,'html.parser')
productlist=soup.find_all('article',class_='event')
for item in productlist:
for link in item.find_all('a',href=True):
productlinks.append(link['href'])
print(productlinks)
Any insights on how i can make it run 1 per link
肥皂起泡泡
相关分类