爬取我的CSDN网页:https://blog.csdn.net/zhaoweiya
import requests 时出现红线,这时候,我们将光标对准requests,按快捷键:alt + enter,pycharm会给出解决之道,这时候,选择install package requests,pycharm就会自动为我们安装了,我们只需要稍等片刻,这个库就安装好了。lxml的安装方式同理
import requests
from lxml import etree
header = {
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"}
html = requests.get(<