|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 桐生战兔丶 于 2021-8-25 09:35 编辑
如图
import requests as req
import os
import json
import re
import time as ti
openfile = open ('C:\\Users\\surface\\Desktop\\GoooodDesigh\\items2.json')
# origin
ori= json.load(openfile)
urllist1 = str(ori[0]['urllist'])
#urllist2 = urllist1.split(',')
#urllist = re.search(r"\[\''([^']+)\'",urllist2)
imglist1 = str(ori[0]['imglist1'])
imglist = imglist1.split(',')
namelist1 = str(ori[0]['namelist1'])
namelist = namelist1.split(',')
#imgpackage = os.mkdir('imgpackage')
headers = {}
headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3875.400 QQBrowser/10.8.4492.400'
for each in range(len(imglist)):
if each == 1 or each == 8:
img = str(imglist[each])
img1 = img[3:-1]
else:
img = str(imglist[each])
img1 = img[2:-1]
imgre = req.get(img1,headers = headers)
imgdata = open('C:\\Users\\surface\\Desktop\\imgpackage\\'+ str(each)+'.'+str(namelist[each]+'.jpg','wb'))
imgencdde = img1.decode(img1,'utf-8')
imgdata.write(imgencdde)
imgdata.close()
time.sleep(1)
报错文本:
Traceback (most recent call last):
File "C:\Users\surface\Desktop\shell.py", line 37, in <module>
imgdata = open('C:\\Users\\surface\\Desktop\\imgpackage\\'+ str(each)+'.'+str(namelist[each]+'.jpg','wb'))
TypeError: decoding str is not supported |
-
-
|