请选择 进入手机版 | 继续访问电脑版

 找回密码
 立即注册
搜索
热搜: Excel discuz
查看: 666|回复: 0

[项目代码] 笔顺图片的批量下载

[复制链接]

419

主题

6万

元宝

66万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
661850
发表于 2022-4-21 14:22:11 | 显示全部楼层 |阅读模式
  1. from lxml import etree
  2. import requests
  3. import xlrd
  4. wb = xlrd.open_workbook(r'E:\新建文件夹\01.xls')
  5. ws = wb.sheet_by_index(0)
  6. lst = ws.col_values(0)[1:]
  7. urllst = []
  8. ua = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36'}
  9. for a in lst:
  10.     re = a.encode('unicode_escape')
  11.     res = str(re).split('\\')[-1].replace("'",'')[1:5]
  12.     url = f'http://bs.kaishicha.com/{res}.html'
  13.     urllst.append(url)
  14. print(lst)
  15. print(urllst)
  16. zidian = dict(zip(lst,urllst))
  17. for zi,i in zidian.items():
  18.     respon = requests.get(url=i)
  19.     respon.encoding = 'gb2312'
  20.     jiexi = etree.HTML(respon.text)
  21.     lianjie = jiexi.xpath('//*[@class="bsfbt"]//@src')
  22.     lianjie = ['http://bs.kaishicha.com/'+d for d in lianjie]
  23.     print(lianjie)
  24.     add = f"E:\新建文件夹\\{zi}.png"
  25.     print(add)
  26.     for l in lianjie:
  27.         pic = requests.get(l).content
  28.         with open(add,'wb') as a:
  29.           a.write(pic)
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|五花八门论坛 ( 豫ICP备15031300号-3 )

GMT+8, 2022-10-7 23:06 , Processed in 0.065287 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表