Python Can';在第页上找不到数据

Python Can';在第页上找不到数据,python,web-scraping,beautifulsoup,Python,Web Scraping,Beautifulsoup,我正试图拉的标题和链接,每个所谓的抽奖名单上的这个网站。然而,当我试图搜集这些数据时,似乎找不到 我尝试过删除页面上的所有链接,但我认为这些“框”可能是通过javascript加载的 我收到的结果是一些与我想要得到的无关的链接。应该有40+的链接显示在这个列表中,但大多数没有显示。任何帮助都会很好的,我已经在这上面呆了一段时间了 由于某些原因,在我抓取时,此链接和其他许多链接没有显示: 我的代码: def raffle\u page\u collection(): chrome_驱动程序()

我正试图拉的标题和链接,每个所谓的抽奖名单上的这个网站。然而,当我试图搜集这些数据时,似乎找不到

我尝试过删除页面上的所有链接,但我认为这些“框”可能是通过javascript加载的

我收到的结果是一些与我想要得到的无关的链接。应该有40+的链接显示在这个列表中,但大多数没有显示。任何帮助都会很好的,我已经在这上面呆了一段时间了

由于某些原因,在我抓取时,此链接和其他许多链接没有显示:

我的代码:

def raffle\u page\u collection():
chrome_驱动程序()
page=requests.get('https://www.soleretriever.com/yeezy-boost-350-v2-black/')
soup=BeautifulSoup(page.text,'html.parser')
product_header=soup.find('h1')。文本
product_colorway=soup.find('h2')。文本
产品库存和发布日期和价格=汤。查找('h3')。文本
container=soup.find(class='main-container')
莱佛士=container.find_all('a'))
抽奖名单=[]
对于莱佛士的商品:
抽奖名单.append(items.get('href'))
打印(抽奖名单)

您应该尝试自动化selenium库。它允许您刮取动态呈现请求(js或ajax)页面数据

试试这个:

from selenium import webdriver
from bs4 import BeautifulSoup
import time

browser = webdriver.Chrome()
browser.get('https://www.soleretriever.com/yeezy-boost-350-v2-black/')
time.sleep(3)

soup = BeautifulSoup(browser.page_source,'html.parser')

product_header = soup.find('h1').text
product_colorway = soup.find('h2').text
product_sku_and_release_date_and_price = soup.find('h3').text

container = soup.find(class_='main-container')
raffles = container.find("div",{"class":"vc_pageable-slide-wrapper vc_clearfix"})

raffle_list = []

for items in raffles.find_all("a",href=True):
    raffle_list.append(items.get('href'))

print(product_header)
print(product_colorway)
print(product_sku_and_release_date_and_price)
print(raffle_list)
O/p:

对于chrome浏览器:

为chrome浏览器安装web驱动程序:

硒教程


页面内容是动态生成的,您不能使用
请求来刮取它。获取
。您应该使用。@DYZ建议您通过类名或标记查找元素并进行迭代(使用selenium)?您必须首先下载使用selenium的页面。请阅读文档。@DYZ将尝试此操作并返回给您,谢谢您的帮助!
Yeezy Boost 350 v2 Black
Black/ Black/ Black
FU9006 | 07/06/19 | $220
['https://www.43einhalb.com/en/adidas-yeezy-boost-350-v2-black-328672#SR', 'https://www.adidas.co.uk/yeezy#SR', 'https://www.allikestore.com/default/adidas-yeezy-boost-350-v2-static-black-black-fu9006-105308.html#SR', 'https://archive1820.com/en/forms/6/yeezy-raffle#SR', 'https://drops.blackboxstore.com/blackbox_launches_view/catalog/product/view/id/22296/s/yeezy-boost-350-v2#SR', 'https://woobox.com/4szm9v#SR', 'https://launches.endclothing.com/product/yeezy-boost-350-v2-fu9006#SR', 'https://www.instagram.com/p/ByEIHSHDSY6/', 'https://www.instagram.com/p/ByFG1G0lWf7/', 'https://releases.footshop.com/adidas-yeezy-boost-350-v2-agqn6WoBJZ9y4RSnzw9G#SR', 'https://launches.goodhoodstore.com/launches/yeezy-boost-350-v2-black-33#SR', 'https://www.hervia.com/launches/yeezy-350#SR', 'https://www.hibbett.com/adidas-yeezy-350-v2-black-mens-shoe/M0991.html#SR', 'https://reporting.jdsports.co.uk/cgi-bin/msite?yeezy_comp+a+0+0+0+0+0&utm_source=RedEye&utm_medium=Email&utm_campaign=Yeezy%20Boost%20351%20Clay&utm_content=0905%20Yeezy%20Clay#SR', 'https://www.instagram.com/p/ByDnK6uH6kE/', 'https://www.nakedcph.com/yeezy-boost-v2-350-static-black-raffle/s/635#SR', 'https://www.instagram.com/p/ByIXT8zHvYz/', 'https://launches.sevenstore.com/launch/yeezy-boost-350-v2-black-4033024#SR', 'https://shelta.eu/news/adidas-yeezy-boost-350-v2-black-fu9006x#SR', 'https://www.instagram.com/p/ByDI_6JAfty/', 'https://www.sneakersnstuff.com/en/product/38889/adidas-yeezy-350-v2#SR', 'https://www.instagram.com/p/ByHtt3HFkE0/', 'https://www.instagram.com/p/ByCaKR7Cde1/', 'https://tres-bien.com/adidas-yeezy-boost-350-v2-black-fu9006-fw19#SR', 'https://yeezysupply.com/products/yeezy-boost-350-v2-black-june-7-2019#SR']