【发布时间】:2016-09-10 19:32:30
【问题描述】:
我试图抓取 Flipkart.com(我随机打开了一个显示 60 种产品的类别)。
但是,当我搜索所有链接时使用BeautifulSoup,我没有得到指向每个产品的链接。我获得了 37 个链接,其中没有一个指向产品描述页面....帮助!!!
import requests
from bs4 import BeautifulSoup
# a random product listing page
url='https://www.flipkart.com/search?q=mobile&sid=tyy/4io&as=on&as-show=on&otracker=start&as-pos=1_1_ic_mobile'
r=requests.get(url)
soup=BeautifulSoup(r.text,from_encoding="utf-8")
links=soup.find_all('a')
它给出了除了链接toproduct descrtiption页面之外的所有链接。
【问题讨论】:
-
data-reactid在返回的第一个 url 中为您提供了一个很好的线索来了解原因
标签: python-3.x web-scraping beautifulsoup