Skip to main content

从浏览器轻松复制标题

项目描述

复制头

方便的从浏览器

本项目是从https://github.com/scrapy/w3lib修改过来的

要修改请看https://github.com/scrapy/w3lib/issues/90为什么

示例代码

from copyheaders import headers_raw_to_dict
import requests

headers_raw = b"""Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding:gzip, deflate, br
Accept-Language:zh-CN,zh;q=0.8,zh-TW;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Cookie:_gauges_unique_year=1; _gauges_unique=1; _gauges_unique_hour=1; _gauges_unique_day=1; _gauges_unique_month=1
Host:httpbin.org
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"""

headers = headers_raw_to_dict(headers_raw)
# 然后就可以在requests中直接用了
z = requests.get('https://httpbin.org/',headers=headers)

安装

  • pip install copyheaders

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

copyheaders-0.0.2.tar.gz (3.1 kB 查看哈希

已上传 source

内置分布

copyheaders-0.0.2-py3-none-any.whl (3.8 kB 查看哈希

已上传 py3