simple-request-framework


Namesimple-request-framework JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/0Chencc/
SummaryEncapsulates a framework for requests to request json corresponding package api, while saving the results locally
upload_time2023-09-24 15:42:15
maintainer
docs_urlNone
author0chencc
requires_python
licenseGNU GPLv3 License
keywords requests framework api json save
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SimpleRequestsFramework

## Description
This is a simple will be used to request requests wrapped up response package is json at the same time the content will be stored locally api package . Support for GET and POST requests , while supporting multiple proxy protocols , you can preset the Header and other related information .

## Installation
```bash
pip install simple-requests-framework
```

## Usage
```python
from SimpleRequestFramework import SimpleRequestFramework

custom_headers = {
    "User-Agent": "CustomUserAgent/1.0",
    "Authorization": "Bearer YOUR_TOKEN"
}
# new a framework instance, and set the save directory, use proxy, proxy type, proxy address, and custom headers
framework = SimpleRequestFramework(
    save_directory="output_files",
    use_proxy=True,
    proxy_type="http",
    proxy_address="http://127.0.0.1:8080",
    headers=custom_headers
)

# GET request example
get_url = "https://api.ip.sb/ip"
params = {
    "param1": "value1",
    "param2": "value2"
}
framework.fetch_and_save(get_url, "output_get.json", method="GET", params=params)

# POST request example
post_url = "https://httpbin.org/post"
data = {
    "data1": "value1",
    "data2": "value2"
}
framework.fetch_and_save(post_url, "output_post.json", method="POST", data=data)
```
Also supports configuration of framework instances as json files


create a json file named config.json
```json
{
    "save_directory": "output_files",
    "use_proxy": true,
    "proxy_type": "http",
    "proxy_address": "http://127.0.0.1:8080",
    "headers": {
      "User-Agent": "CustomUserAgent/1.0",
      "Authorization": "Bearer YOUR_TOKEN"
    }
}
```

```python
from SimpleRequestFramework import SimpleRequestFramework

framework = SimpleRequestFramework(config_json="config.json")
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/0Chencc/",
    "name": "simple-request-framework",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "requests,framework,api,json,save",
    "author": "0chencc",
    "author_email": "admin@hi-ourlife.com",
    "download_url": "https://files.pythonhosted.org/packages/ed/43/3f7393cd4e99082035c27ceb6d6177b49894b14d6c16253e2f0de219f35f/simple-request-framework-0.0.2.tar.gz",
    "platform": null,
    "description": "# SimpleRequestsFramework\n\n## Description\nThis is a simple will be used to request requests wrapped up response package is json at the same time the content will be stored locally api package . Support for GET and POST requests , while supporting multiple proxy protocols , you can preset the Header and other related information .\n\n## Installation\n```bash\npip install simple-requests-framework\n```\n\n## Usage\n```python\nfrom SimpleRequestFramework import SimpleRequestFramework\n\ncustom_headers = {\n    \"User-Agent\": \"CustomUserAgent/1.0\",\n    \"Authorization\": \"Bearer YOUR_TOKEN\"\n}\n# new a framework instance, and set the save directory, use proxy, proxy type, proxy address, and custom headers\nframework = SimpleRequestFramework(\n    save_directory=\"output_files\",\n    use_proxy=True,\n    proxy_type=\"http\",\n    proxy_address=\"http://127.0.0.1:8080\",\n    headers=custom_headers\n)\n\n# GET request example\nget_url = \"https://api.ip.sb/ip\"\nparams = {\n    \"param1\": \"value1\",\n    \"param2\": \"value2\"\n}\nframework.fetch_and_save(get_url, \"output_get.json\", method=\"GET\", params=params)\n\n# POST request example\npost_url = \"https://httpbin.org/post\"\ndata = {\n    \"data1\": \"value1\",\n    \"data2\": \"value2\"\n}\nframework.fetch_and_save(post_url, \"output_post.json\", method=\"POST\", data=data)\n```\nAlso supports configuration of framework instances as json files\n\n\ncreate a json file named config.json\n```json\n{\n    \"save_directory\": \"output_files\",\n    \"use_proxy\": true,\n    \"proxy_type\": \"http\",\n    \"proxy_address\": \"http://127.0.0.1:8080\",\n    \"headers\": {\n      \"User-Agent\": \"CustomUserAgent/1.0\",\n      \"Authorization\": \"Bearer YOUR_TOKEN\"\n    }\n}\n```\n\n```python\nfrom SimpleRequestFramework import SimpleRequestFramework\n\nframework = SimpleRequestFramework(config_json=\"config.json\")\n```\n",
    "bugtrack_url": null,
    "license": "GNU GPLv3 License",
    "summary": "Encapsulates a framework for requests to request json corresponding package api, while saving the results locally",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/0Chencc/"
    },
    "split_keywords": [
        "requests",
        "framework",
        "api",
        "json",
        "save"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ed433f7393cd4e99082035c27ceb6d6177b49894b14d6c16253e2f0de219f35f",
                "md5": "2345705fef00b70ad216212ccdabdd6b",
                "sha256": "c5aecc4ab6ea4e513ad8b54c3b242299e4bcc3a0a7d57b48612122fa6dcac45c"
            },
            "downloads": -1,
            "filename": "simple-request-framework-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2345705fef00b70ad216212ccdabdd6b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3633,
            "upload_time": "2023-09-24T15:42:15",
            "upload_time_iso_8601": "2023-09-24T15:42:15.690910Z",
            "url": "https://files.pythonhosted.org/packages/ed/43/3f7393cd4e99082035c27ceb6d6177b49894b14d6c16253e2f0de219f35f/simple-request-framework-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-24 15:42:15",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "simple-request-framework"
}
        
Elapsed time: 1.97805s