def GetImgData(html_img):
soup = BeautifulSoup(html_img,'lxml')
img = soup.select('#image')
for src in img:
img_src = src.get('src')
return(img_src)
page = num = 1
sum = int(input("请输入下载页数:"))
while page <= sum:
Target_url = 'http://konachan.net/post?page={}'.format(page)
html = GetImg(GetHtml(Target_url))
print("正在下载第",page,"页")
page+=1
for i in html:
src = i.text[4:40]
Write(src)
down = GetImgData(GetImgHtml(src))
urllib.request.urlretrieve(down,"{}.jpg".format(num))
print("正在下载第",num,"张")
print(src)
num+=1