Skip to main content

create requests params from file,file is created by Firefox Header

Project description

# 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方法请求

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

requests_from_file-2.2.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file requests_from_file-2.2.tar.gz.

File metadata

  • Download URL: requests_from_file-2.2.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for requests_from_file-2.2.tar.gz
Algorithm Hash digest
SHA256 d4a5e74ed42dc2b0b9b0291e092d3aa6da78199d4765f1b3b0c90ec1653b1b09
MD5 3e6f175fc6a77d076d53706d7fdb37d9
BLAKE2b-256 024aab35fcac3d8c141a986f36aea41cce548fb98ffa1f6d75ec4e348db7dfc3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page