无法通过python中的url下载图像

时间:2020-08-04 01:28:01

标签: python python-3.x web web-crawler

我在网页的源代码中找到了图像的地址。
相关内容如下:

<div class="fwr_page_box">
    <div class="fwr_page" id="PageContainer_0" style="width: 1200px; height: 1696px; margin-left: 815px;">
        <div id="Wrap_0" class="fwr_page_wrap border  fwr_hidden" style="width: 1200px; height: 1696px;"></div>
        <div class="loadingBg" id="loadingBg0" style="width:1200;height:1696;">
            <img alt="" src="http://162.105.134.188/store/z6MY4xILLZ4Adov3uF7aOQ11/P01_00001.jpg" id="ViewContainer_BG_0" class="border  fwr_page_bg_image">
        </div>
    </div>
</div>

然后,我可以使用chrome浏览器提取网址(http://162.105.134.188/store/z6MY4xILLZ4Adov3uF7aOQ11/P01_00001.jpg),然后手动下载。数字大小约为87 kb。

但是,当我尝试通过 wget python urllib

批量下载这些图像时
end_page = 117
for i in range(0,end_page,1):
    os.system("wget http://162.105.134.188/store/z6MY4xILLZ4Adov3uF7aOQ11/P01_%s.jpg" %"{:05d}".format(i))

可以下载这些文件,而图形大小仅为82位,没有任何内容。

1 个答案:

答案 0 :(得分:2)

带有图像的动态html由Javascript加载,而wget或urllib则不加载

使用selenium模拟一个Chrome浏览器,然后从中提取内容