【问题标题】:how to scrape all the links of image of product present in flipkart如何抓取flipkart中存在的产品图像的所有链接
【发布时间】:2016-11-16 06:54:40
【问题描述】:

我正在尝试抓取此链接https://www.flipkart.com/samsung-galaxy-nxt-gold-32-gb/p/itmemzd4gepexjya?pid=MOBEMZD4KHRF5VZX 中所有不同图像的网址。我正在尝试使用python的beautifulsoup模块。但这种方法没有成功。我无法理解 Flipkart.com 的代码结构以及为什么它没有返回所需的数据。 我正在尝试的代码如下

from bs4 import BeautifulSoup
import urllib
from pprintpp import pprint
import pandas as pd
import requests
from time import sleep

x=requests.get("https://www.flipkart.com/samsung-galaxy-nxt-gold-32-gb/p/itmemzd4gepexjya?pid=MOBEMZD4KHRF5VZX").content
#x= urllib._urlopener("https://www.flipkart.com/jbl-t250si-on-the-ear-headphone/p/itmefbgezsc72mgt?pid=ACCEFBGAK5ZDTBF7&")
soup2 = BeautifulSoup(x, 'html.parser')
data=[]
for j in soup2.find_all('img', attrs={'class':"sfescn"}):
    data+=[j]
    print data

【问题讨论】:

  • 你能告诉我们你的代码吗?
  • 请展示你到目前为止的尝试?
  • 我认为您只获得了 2 个图片链接。对吧?
  • 这段代码什么也没返回,根本没有链接
  • 您打印了x 吗?不应该是x.text

标签: python web-scraping beautifulsoup


【解决方案1】:

好吧,我可以清楚地看到页面源代码中没有移动图像的链接。 所以我建议使用工具 Fiddler 或浏览器开发人员的控制台来跟踪实际数据的来源,很可能它来自 json 响应类型的请求。 我不熟悉beautifulsoup,我一直在使用scrapy。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-06
    • 1970-01-01
    • 2017-11-21
    • 2019-11-07
    • 2017-04-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-30
    相关资源
    最近更新 更多