爬虫初探----requests模块
# requests 模块
# --urllib模块
# --requests模块
# requests模块; 模拟浏览器发送请求
# 使用 :
# ---指定url
# ---发起请求
# ---获取响应数据
# ---持久化存储
#
######## 爬取搜狗首页的页面数据 ###########
import requests
# 指定url
url = 'https://www.sogou.com/'
# 发起请求
response = requests.get(url=url)
# 获取相应数据 text返回的是字符串形式的相应数据
page_text = response.text
print(page_text)
with open('./sougou.html','w',encoding='utf-8') as fp:
fp.write(page_text)
print('爬取数据结束')