爬虫大作业
https://news.duote.com/202004/199549_2.html
前些个天王力宏的饶舌惊艳四座,就想着爬一个他的歌词
然后
通过mooc和同学的经验学习了爬虫
但刚开始requests库怎么都用不起来,在cmd才知道是python的版本不兼容,于是卸载了又重新装,像同专业人学习,才终于装好了库
源代码:
import requests
def f(a):
r=requests.get(a)
r.raise_for_status()
r.encoding = r.apparent_encoding
return r.text
a='https://news.duote.com/202004/199549_2.html'
print(f(a))

然后效果如下:


浙公网安备 33010602011771号