📜  python 请求获取标题 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:36.705000             🧑  作者: Mango

代码示例1
#!/bin/python
import requests
from bs4 import BeautifulSoup

response = requests.get("https://www.example.com")

if repsonse.status_code == 200:
    soup = BeautifulSoup(response.content, "html.parser")

    # will only find the first match, presumably the page title
    title = soup.find("title").get_text()