def manhua(html:str):
rr =requests.get(html,headers=headers)
rr.encoding="utf-8"
duo=[]
manhua=BeautifulSoup(rr.text,'html.parser')
dizhi=manhua.find('ol',class_="links-of-books num_div")
for a in dizhi.find_all('li',class_='sort_div'):
duo=('https://www.manhuadb.com'+str(a.find('a').get('href')))
return duo
def download(url2:str,page:int):
r4 = requests.get(url2+'.html',headers=headers)
r4.encoding="utf-8"
dj = BeautifulSoup(r4.text,'lxml')
name = dj.find('h1',class_='h2 text-center mt-3 ccdiv-m').getText()
mkdir(name)
image=requests.get(reponse,headers=headers)
time.sleep(0.1)
filename='{}/{}/{}'.format('yiteng',name,name+str(x)+'.jpg')
with open(filename,'wb') as fpp:
fpp.write(image.content)
print('成功第{}图片'.format(str(x)))
if reponse is None :
continue
print('全部保存成功!')
#if not os.path.exists('yiteng'):
# os.makedirs('yiteng')
#with open('teng','wb') as fpp:
# fpp.write(img.content)
在追加一个问题
def manhua(html:str):
rr =requests.get(html,headers=headers)
rr.encoding="utf-8"
duo=[]
manhua=BeautifulSoup(rr.text,'html.parser')
dizhi=manhua.find('ol',class_="links-of-books num_div")
for a in dizhi.find_all('li',class_='sort_div'):
duo=('https://www.manhuadb.com'+str(a.find('a').get('href')))
return duo
这段里面,因为有些漫画里面包含了三卷,多以return无法返回多个值,我只能把所有值赋值到列表,然后在用return返回到主main里 这样在传给download能够爬取吗?
我这样写对不对