当前位置:网站首页>爬虫练习题(三)
爬虫练习题(三)
2022-07-06 23:52:00 【InfoQ】
'''
1.分析网页:
https://www.6pian.cn/
https://www.6pian.cn/xq.html
https://www.6pian.cn/xq/1/0.html
https://www.6pian.cn/xq/2/0.html
https://www.6pian.cn/xq/3/0.html
'''
import urllib.request
start = int(input("请输入起始页"))
end = int(input("请输入结束页"))
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.66 Safari/537.36 Edg/103.0.1264.44'
}
for n in range(start, end + 1):
url = 'https://www.6pian.cn/xq/{}/0.html'.format(n)
print(url)
q = urllib.request.Request(url,headers=headers)
response = urllib.request.urlopen(q)
with open(f'第{n}页.html','w',encoding='utf-8')as f:
f.write(response.read().decode('utf-8'))




边栏推荐
- AI人脸编辑让Lena微笑
- 京东商品详情页API接口、京东商品销量API接口、京东商品列表API接口、京东APP详情API接口、京东详情API接口,京东SKU信息接口
- Is the human body sensor easy to use? How to use it? Which do you buy between aqara green rice and Xiaomi
- Unity让摄像机一直跟随在玩家后上方
- In memory, I moved from CSDN to blog park!
- 漏电继电器JD1-100
- batch size设置技巧
- Mapbox Chinese map address
- WEB架构设计过程
- Make web content editable
猜你喜欢
5. Data access - entityframework integration
Design, configuration and points for attention of network specified source multicast (SSM) simulation using OPNET
English语法_名词 - 所有格
Under the trend of Micah, orebo and apple homekit, how does zhiting stand out?
Jhok-zbg2 leakage relay
Life experience of an update statement
The year of the tiger is coming. Come and make a wish. I heard that the wish will come true
Mysql database learning (8) -- MySQL content supplement
Leetcode 1189 maximum number of "balloons" [map] the leetcode road of heroding
JVM(十九) -- 字节码与类的加载(四) -- 再谈类的加载器
随机推荐
Under the trend of Micah, orebo and apple homekit, how does zhiting stand out?
Life experience of an update statement
Paper reading [semantic tag enlarged xlnv model for video captioning]
Mybaits multi table query (joint query, nested query)
【js组件】date日期显示。
Use Zhiyun reader to translate statistical genetics books
利用OPNET进行网络仿真时网络层协议(以QoS为例)的使用、配置及注意点
Tablayout modification of customized tab title does not take effect
Flink SQL 实现读写redis,并动态生成Hset key
[Oracle] simple date and time formatting and sorting problem
论文阅读【MM21 Pre-training for Video Understanding Challenge:Video Captioning with Pretraining Techniqu】
nodejs获取客户端ip
High voltage leakage relay bld-20
DOM node object + time node comprehensive case
Jhok-zbl1 leakage relay
1. AVL tree: left-right rotation -bite
5. 数据访问 - EntityFramework集成
Unity keeps the camera behind and above the player
照片选择器CollectionView
Intelligent annotation scheme of entity recognition based on hugging Face Pre training model: generate doccano request JSON format