# 步骤
# 指定url
# 发起请求
# 获取响应数据
# 持久化存储,存响应数据
# 爬取搜狗首页的页面数据
import requests
if __name__ == "__main__":
#step1
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:#存到html文件里
fp.write(page_text)
print('爬取数据结束!!!')
01-25
482
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-27
08-21