我正在尝试学习如何抓取网站,因此不使用API。我正在尝试抓取eBay的网站,我的脚本将打印双URL。我做了尽职调查,并在Google / StackOverflow帮助中进行了搜索,但是找不到任何解决方案。提前致谢。
driver.get('https://www.ebay.com/sch/i.html?_from=R40&_nkw=watches&_sacat=0&_pgn=' + str(i))
soup = BeautifulSoup(driver.page_source, 'lxml')
driver.maximize_window()
tempList = []
for link in soup.find_all('a', href=True):
if 'itm' in link['href']:
print(link['href'])
tempList.append(link['href'])
只需在搜索所有链接时添加类名即可,希望这会有所帮助。
i=1
driver.get('https://www.ebay.com/sch/i.html?_from=R40&_nkw=watches&_sacat=0&_pgn=' + str(i))
soup = BeautifulSoup(driver.page_source, 'lxml')
driver.maximize_window()
tempList = []
for link in soup.find_all('a',class_='s-item__link', href=True):
if 'itm' in link['href']:
print(link['href'])
tempList.append(link['href'])
print(len(tempList))
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句