爬虫入门01
第一天真的很简单,跟着我,你也行!
import requestsfrom bs4 importBeautifulSoupurl ="https://www.baidu.com"headers ={"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0"}response = requests.get(url, headers=headers)soup =BeautifulSoup(response.text,"lxml")title = soup.select_one('title')print("页面标题:", title.text)
爬虫入门01结束
第一天真的很简单,跟着我,你也行!