下载站

展开
精品推荐
python爬取半次元图片源码

python爬取半次元图片源码

源码相关大小:994.30MB语言: / 类别:编程书集系统: / WinXP, Win7, win8 提供:
应用介绍

python爬取半次元图片源码,由大神自制的python爬取工具,本源码针对半次元图片平台,可以爬取最新的网站图片资源,支持自定义保存目录,非常方便,需要requests库的支持,想要相关源码资源的朋友们不要错过哦!

python爬取半次元图片源码说明:

需要安装requests库,在运行脚本的文件夹下新建一个img文件夹

源码也可供大家学习和参考。

python爬取半次元图片源码一览:

importrequests

importre

url='https://bcy.net/coser/toppost100'?#要进行抓取的url

web_url="https://bcy.net"?#官方网站

file='img/'?#文件的保存路径最后加反斜杠

headers={

'user-agent':'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/75.0.3770.142Safari/537.36'

}

#获取抓取数据页面

data=requests.get(url,headers=headers).text

wi_url_id=re.findall('<ahref=".*?class="dbposrovf-usaubk"',data)

#对抓取图片单独页面url进行遍历

forsinwi_url_id:

wi_id=web_url+s.lstrip('<ahref="').rstrip('"class="dbposrovf-usaubk"')

n_data=requests.get(wi_id,headers=headers).text?#获取单独的图片页面数据

json_data=re.findall('"{.*?}"',n_data).lstrip('"').rstrip('}}"')

n_http=re.findall('"path.*?w650',json_data)

#对图片url进行遍历

forbinn_http:

try:

img_data=b.lstrip('"path\\":\\"s')+'.image'

img_url='https:/'+img_data.replace('u002F','').replace('\\\\','/')

img=requests.get(img_url,headers=headers).content?#获取图片数据

img_name=img_url.rstrip('.jpg"/>~tplv-banciyuan-w650.image')[-31:]?#获取图片名

#对图片进行保存

withopen(file+img_name+'.jpg"/>','wb')asf:

f.write(img)

print('以保存,图片url:'+img_url)

except:

print('保存失败')

python爬取相关视频:

Tags:半次元图片,python爬取,源码.

应用推荐查看更多
热门下载查看更多
精选应用
点击查看更多
专题合集查看更多
热门专题查看更多
友情链接0投诉联系:ichaoinc@gmail.com