python通过伪装头部数据抵抗反爬虫
来源:互联网 发布:锋利的jquery第2版源码 编辑:程序博客网 时间:2024/06/06 12:52
0x00 环境
系统环境:win10
编写工具:JetBrains PyCharm Community Edition 2017.1.2 x64
python 版本:python-3.6.2
抓包工具:Fiddler 4
0x01 头部数据伪装思路
通过http向服务器提交数据,以下是通过Fiddler 抓取python没有伪装的报文头信息
GET /u012870721 HTTP/1.1Accept-Encoding: identityHost: blog.csdn.netUser-Agent: Python-urllib/3.6Connection: close
Python-urllib/3.6很明显啊,我们暴露了。现在要问了,该怎么!模拟浏览器,让自己伪装成浏览器,一下是浏览器访问发送的头部数据Connection: keep-aliveUpgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36Referer: http://write.blog.csdn.net/postlistAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.8
0x02代码实现
from urllib import requesthtml_url = "http://blog.csdn.net/u012870721";#伪装构造头header ={ "Connection": "keep-alive", "Upgrade-Insecure-Requests": "1", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36", "Accept":" text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding": "gzip,deflate", "Accept-Language": "zh-CN,zh;q=0.8"};#int main()#{req = request.Request(url=html_url, headers=header);resp = request.urlopen(req);# return 0;# }
伪装后进行发送的信息头
GET /u012870721 HTTP/1.1Host: blog.csdn.netConnection: closeUpgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8Accept-Encoding: gzip,deflateAccept-Language: zh-CN,zh;q=0.8
阅读全文
0 0
- python通过伪装头部数据抵抗反爬虫
- python网络爬虫 - 如何伪装逃过反爬虫程序
- python 爬虫完美伪装
- 2.python爬虫伪装
- Python爬虫伪装
- python爬虫浏览器伪装
- python 爬虫 伪装成 chrome
- Python伪装浏览器爬虫读取网页内容
- python爬虫伪装成浏览器访问
- Python伪装浏览器请求爬虫豆瓣小组
- Python伪装浏览器爬虫读取网页内容
- fake-useragent,python爬虫伪装请求头
- 【Python】反爬虫
- 一.python 反爬虫
- Python -bs4反爬虫解决方法
- Python反爬虫系列方法
- Python 网络爬虫系列(二) --- 伪装成浏览器访问
- python爬虫系列(四):请求伪装的做法
- Scala 中下划线的用途
- liunx常用命令
- Gobblin采集kafka数据
- C++ SOCKET通信模型(五)poll
- 基于 Hive 的文件格式:RCFile 简介及其应用
- python通过伪装头部数据抵抗反爬虫
- RDD、DataFrame和DataSet的区别
- OSG 对线或者点组成的模型选取
- Spark计算均值
- 实用教程|快速搭建自动导航机器人(一)
- Kafka0.10的新特性一览
- 《Kafka Stream》调研:一种轻量级流计算模式
- Spark的DataFrame的窗口函数使用
- 欢迎使用CSDN-markdown编辑器