Python 无法从剪贴画中提取图像链接
我正在使用scrapy从网站中提取产品的图像链接,但返回的输出是一个空列表,我尝试了所有组合,请帮助 '''Python 无法从剪贴画中提取图像链接,python,html,web-scraping,scrapy,Python,Html,Web Scraping,Scrapy,我正在使用scrapy从网站中提取产品的图像链接,但返回的输出是一个空列表,我尝试了所有组合,请帮助 ''' ''我认为这可能与网站政策有关。 下面的代码非常适合这个网站 url = "http://hdresim.net/" source = requests.get(url).text soup = BeautifulSoup(source, "lxml") main = soup.find("div", attrs={"
''我认为这可能与网站政策有关。 下面的代码非常适合这个网站
url = "http://hdresim.net/"
source = requests.get(url).text
soup = BeautifulSoup(source, "lxml")
main = soup.find("div", attrs={"class":'icerik'})
for i in main.findAll("img"):
print(i["src"])
结果如下:
http://hdresim.net/resimler/r6/k_karinca(10).jpg
http://hdresim.net/resimler/r3/k_deniz_canlilari(38).jpg
http://hdresim.net/resimler/r5/k_sonbahar14(44).jpg
http://hdresim.net/resimler/r7/k_yaz16(3).jpg
..
但当我尝试同样的方法来访问你们的站点时,我会得到一个空列表
url = "https://www.flipkart.com/clothing-and-accessories/topwear/pr?sid=clo%2Cash&otracker=categorytree&p%5B%5D=facets.ideal_for%255B%255D%3DMen"
source = requests.get(url).text
soup = BeautifulSoup(source, "lxml")
main = soup.findAll("div", attrs={"class":"_13oc-S"})
for images in soup.findAll("img", attrs={"class":"_2r_T1I"}):
print(images["src"])
url = "https://www.flipkart.com/clothing-and-accessories/topwear/pr?sid=clo%2Cash&otracker=categorytree&p%5B%5D=facets.ideal_for%255B%255D%3DMen"
source = requests.get(url).text
soup = BeautifulSoup(source, "lxml")
main = soup.findAll("div", attrs={"class":"_13oc-S"})
for images in soup.findAll("img", attrs={"class":"_2r_T1I"}):
print(images["src"])