各位板大好,目前小弟想要爬取1-n頁的特定標題,可目前都只能抓到第n頁
請問哪邊可以做修正呢? 程式碼如下:
page = 10
products = []
keyword = "益生菌"
for page in range(1, page+1):
url =
'https://tw.mall.yahoo.com/search/product?p={}&pg={}'.format(keyword, page)
headers = {'User-Agent':"Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36"}
r = requests.get(url, headers = headers )
soup = BeautifulSoup(r.text,"html.parser")
s = soup.find_all('span',class_="BaseGridItem__title___2HWui")
s