python第一个爬虫

import requests  

# 爬取地址百度首页
url = "https://www.baidu.com/"

# 请求头
headers = {
    
    
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
}

# 相应结果
response = requests.get(url=url,headers=headers)
# 拿到网页源代码
print(response.text)

おすすめ

転載: blog.csdn.net/qq_53075298/article/details/121458530