Skip to main content

# requests_from_file 从火狐文件中创造requests请求体

因为某种原因,我需要从火狐等浏览器中抓取请求信息,每次都自己根据请求构造太过麻烦,所以用这个来帮我从文件中读取请求配置

## install 使用pip `python pip install requests_from_file ` ## 使用方法 `python from requests_from_file import requestFactory factory=requestsFactory(headerFileName="http/header/file",contentFileName="http/heade/content/file") factory.params r = factory.request() ` 其中 headerFile 是从火狐等浏览器抓取下来的请求头文件,他的样子如下图所示 ` GET /tax_view?keyno=3ceaa2674e137a392d9986ad2f02aa28&ajaxflag=1 HTTP/1.1 Host: www.qichacha.com User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0 Accept: */* Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2 Accept-Encoding: gzip, deflate, br Referer: https://www.qichacha.com X-Requested-With: XMLHttpRequest Cookie: name=cookie;url=ssss; Connection: keep-alive Pragma: no-cache Cache-Control: no-cache ` 而如果是post请求,那么post参数有两种形式, 1. 以json形式发送的,请以 ` Json:[other:params] ` 形式附加在header文件最后

  1. 以multipart发送的,请另存一个文件,并传递给contentFileName参数

## 结果 读入文件后,相应的参数以 headers,json,data,cookies,params形式(和requests对应)保存在params内, 并可以使用requests.request的方法直接请求,也可以使用requestFactory的request方法请求

Metadata

Release files for requests-from-file 2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for requests-from-file 2.2
File Size Uploaded Provenance
requests_from_file-2.2.tar.gz 3.2 kB Without provenance Details

Release files / requests_from_file-2.2.tar.gz

Download URL requests_from_file-2.2.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d4a5e74ed42dc2b0b9b0291e092d3aa6da78199d4765f1b3b0c90ec1653b1b09
BLAKE2b-256 checksum
How to use checksums
024aab35fcac3d8c141a986f36aea41cce548fb98ffa1f6d75ec4e348db7dfc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

Security for requests-from-file 2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page