python nonetype object has no_为什么会出现这个?'NoneType' object has no attribute 'contet

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

import urllib.request

from bs4 import BeautifulSoup

def get_page(url):

kv = {'User-Agent': 'Mozilla/5.0', 'Cookie':'BAIDUID=0156185E725928F549DB48FE0A1DDE69:FG=1; PSTM=1551762939; BIDUPSID=63EAE36946BA95A4145B1A726A4422A2; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; CPROID=0156185E725928F549DB48FE0A1DDE69:FG=1; locale=zh; delPer=0; H_PS_PSSID=1432_21111_28608_28584_28557_28518_28625_28606; PSINO=7; ISBID=0156185E725928F549DB48FE0A1DDE69:FG=1; ISUS=0156185E725928F549DB48FE0A1DDE69:FG=1'}

req = urllib.request.Request(url, headers=kv)

response = urllib.request.urlopen(req)

html = response.read().decode('utf-8', 'ignore')

return html

def find_img(html):

soup = BeautifulSoup(get_page(html), 'html.parser')

my_girl = soup.find_all('img')

for girl in my_girl:

link = girl.get('src')

return link

def save(link):

root = "D://pics//"

path = root + link.split('/')[-1]

r = find_img(link)

with open(path, 'wb') as f:

f.write(r.content)

f.close()

def main():

url = 'https://www.dbmeinv.com/'

pages = 6

for i in range(pages):

i += 1

page_url = url + '?pager_offset=' + str(i)

link = find_img(page_url)

save(link

main()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值