《百年孤独》百度百科的爬取

一、参考网址:https://baike.baidu.com/item/%E7%99%BE%E5%B9%B4%E5%AD%A4%E7%8B%AC/688708?fr=aladdin

二、源代码:

import requests
def A():
try:
r=requests.get(url)
r.raise_for_status()
r.encoding='utf-8'
return r.text
except:
return ""
url='https://baike.baidu.com/item/%E7%99%BE%E5%B9%B4%E5%AD%A4%E7%8B%AC/688708?fr=aladdin'
print(A())

三、成果:

四、只爬取了文字没有爬取图片,可能我的成果难度系数比较低,望进一步学习爬虫熟练运用。

猜你喜欢

转载自www.cnblogs.com/cqyqqx98576/p/12822992.html
今日推荐