我正在尝试从一个网站下载图片。我发现我找不到图片URL的问题就在代码的开头。你知道吗
我有一个问题,urlopen下载的HTML与我在浏览器中得到的不同。你知道吗
网站是here。当我在浏览器中查看HTML时,我可以看到以下部分:
<a href="#" data-trigger="cmg-rotate-big">
<img src="/image/product/eca412b9-9484-4046-8bee-8400fde1d5fe/?width=400" alt="" data-cm-index="0" style="width: 400px; height: 400px; margin-left: 0px; opacity: 1;">
<img src="/image/product/014a128e-fa7b-4817-9d76-7bdf296de8de/?width=400" alt="" data-cm-index="1" style="width: 0px; height: 400px; margin-left: 200px; opacity: 0.5;">
</a>
但根据规则
text = urllib2.urlopen(url).read()
soup = BeautifulSoup(text, "html.parser")
print(soup)
同一部分只是
<a data-trigger="cmg-rotate-big" href="#">
<img alt="" data-cm-index="0" src=""/>
<img alt="" data-cm-index="1" src=""/>
</a>
所以我可以提取图像的SRC,因为它丢失了。。请问哪里有问题?你知道吗
谢谢你!你知道吗
src href在那里。不需要模拟javascript。你知道吗
输出:
如果希望宽度=400:
输出:
相关问题 更多 >
编程相关推荐