爬取搜狗首页的页面数据

# 爬取搜狗首页的页面数据
import requests

if __name__ == '__main__':
# 1.指定url
url = 'https://www.sogou.com/'
# 2.发起请求 get请求返回一个response对象
response = requests.get(url=url)
# 3.获取响应数据 返回的是字符串形式的相应数据
page_text = response.text
# 4.持久化存储
with open('./sogou.html', 'wt', encoding='utf-8') as f:
f.write(page_text)