当前位置:网站首页>requests-爬取页面源码数据
requests-爬取页面源码数据
2022-07-24 07:28:00 【不会挂科i】
requests
- 这是爬虫中一个基于网络请求的模块
- 作用:模拟浏览器发起请求。
- 编码流程:
- 1.指定url
- 2.发起请求
- 3.获取响应数据(爬取到的页面源码数据)
- 4.持久化存储
1 爬取搜狗首页的页面源码数据
import requests
# 指定url
url = 'https://www.sogou.com/'
# 发起请求 get方法的返回值为相应对象
response = requests.get(url=url)
# 获取相应数据
# .text:返回的是字符串类型的响应数据
page_text = response.text
# 持久化存储
with open('./sougou.html', 'w', encoding='utf-8') as fp:
fp.write(page_text)
运行后的效果
关注专栏查看更多详细内容
边栏推荐
- stdafx.h 简介及作用
- 【信息系统项目管理师】第七章 复盘成本管理知识架构
- C语言文件操作
- Aggregated new ecological model - sharing purchase, membership and reward system
- mysql查询当前节点的所有父级
- From the perspective of CIA, common network attacks (blasting, PE, traffic attacks)
- 单场GMV翻了100倍,冷门品牌崛起背后的“通用法则”是什么?
- Chapter007-FPGA学习之IIC总线EEPROM读取
- Advanced part of Nacos
- 【云原生】MySql索引分析及查询优化
猜你喜欢

Three implementation methods of single sign on
![[leetcode] 11. Container with the most water - go language solution](/img/42/3a1839dd768a5f02dc2acb5bd66438.png)
[leetcode] 11. Container with the most water - go language solution

Bookkeeping app: xiaoha bookkeeping 2 - production of registration page

解压主播狂揽4000w+播放,快手美食赛道又添新风向?

文件上传下载Demo

周杰伦直播超654万人观看,总互动量破4.5亿,助力快手再破纪录

C语言文件操作

Jackson parsing JSON detailed tutorial

Decompress the anchor and enjoy 4000w+ playback, adding a new wind to the Kwai food track?

服务漏洞&FTP&RDP&SSH&rsync
随机推荐
libsvm 使用参数的基础知识笔记(1)
【云原生】MySql索引分析及查询优化
B. Also Try Minecraft
拉普拉斯(Laplace)分布
Part II - C language improvement_ 3. Pointer reinforcement
Write three piece chess in C language
Win10 sound icon has no sound
项目中数据库插入大批量数据遇到的问题
django.db.utils. OperationalError: (2002, “Can‘t connect to local MySQL server through socket ‘/var/r
17. What is the situation of using ArrayList or LinkedList?
Jenkins 详细部署
numpy.inf
The shortest distance of Y axis of 2D plane polyline
My creation anniversary
[tips] a simple method to create a version control project
csdn,是时候说再见!
【HiFlow】腾讯云HiFlow场景连接器实现校园信息管理智能化
Bookkeeping app: xiaoha bookkeeping 1 - production of welcome page
学习笔记-分布式事务理论
Paper reading: hardnet: a low memory traffic network
