5fcd8d4f86040755.jpg_fo742.jpg

from bs4 import BeautifulSoup
import requests
from parsel import Selector

# requests.get(url)
url = "https://www.baidu.com/"
response = requests.get(url)
response.encoding = response.apparent_encoding

# BeautifulSoup
soup = BeautifulSoup(response.text, "html.parser")
title = soup.find("title")
print(title.text)


# Selector
sel = Selector(text=response.text)
title = sel.css("title::text").extract_first()
print(title)

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code