----爬虫(某东)----


import urllib.request as eq
import re
url='https://search.jd.com/Search?keyword=%E5%85%85%E6%B0%94%E5%A8%83%E5%A8%83&enc=utf-8&qrst=1&rt=1&stop=1&vt=2&wq=%E5%85%85%E6%B0%94%E5%A8%83%E5%A8%83&page=3&s=63&click=0'
html1=eq.urlopen(url).read()
html1=str(html1)
pat2='<img width="220" height="220" class="err-product" data-img="1" src="//(.+?\.jpg)" />'
imagelist=re.compile(pat2).findall(html1)
print(imagelist)
x=1
for imageurl in imagelist:
    imagename='D:/python36/pachong/img1/'+str(x)+'.jpg'
    imageurl='http://'+imageurl
    print(imageurl)
    try:
        eq.urlretrieve(imageurl,filename=imagename)
    except eq.URLError as e:
        if hasattr(e,'code'):
            x=x+1
        if hasattr(e,'reason'):
            x=x+1
    x=x+1

  

转载于:https://www.cnblogs.com/w-s-l123/p/10046537.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值