# 引用库
import requests
from bs4 import BeautifulSoup
# 模拟浏览器代理
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/82.0.4051.0 Safari/537.36 Edg/82.0.425.0'}
# 赋值给url
url = 'https://blog.csdn.net/baidu_17201253/article/details/118699532'
# 将获取到的数据存到response变量中
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text,'html.parser')
pagetitle = soup.find("title")
print(pagetitle.get_text)
Python爬虫——获取整个网页的标题
最新推荐文章于 2024-08-14 15:24:20 发布