根据图片链接规律爬取图片并下载

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/TH_NUM/article/details/76099945
import requests
import urllib
import re
from PIL import Image
cou=1
for i in range(0,300):
    print ('下载')
    num=''
    if i<9:
        num=num+'00'+str(i)
    elif 10<=i<=99:
        num=num+'0'+str(i)
    else:
        num=str(i)
    url='http://103.10.86.34/upload_files/gf/fg/little/xs_11/11 ('+num+').jpg'
    headers = {'Cookie': 'PHPSESSID=4j58cd9rv68sq49lnui7idkf45'}
    content=requests.get(url=url,headers=headers).content
    f = open('d:/python3WorkSpace/zhihu/11/'+str(cou)+'.png',"wb")
    cou=cou+1
    f.write(content)
f.close()
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页