#需求:爬取搜狗首页的页面数据(ps:只爬取了页面,没有搜索功能)
import requests
#step1:指定url
url = "https://www.sogou.com/"
#step2:发起请求 get方法会返回一个响应对象
response = requests.get(url=url)
#step3:获取响应数据 .text返回的是字符串形式的响应数据
page_text = response.text
print(page_text)
#step4:持久化存储
with open('./sogou.html','w',encoding='utf-8') as fp :
fp.write(page_text)
print("爬取结束")
python爬虫1:爬取搜狗首页的页面数据
最新推荐文章于 2024-07-31 14:30:10 发布