Skip to main content

在启动了Clash的情况下,requests发送请求会报错,于是稍微封装了下

Project description

requestspr

PyPI PyPI - License

在启动了Clash的情况下,requests发送请求会报错,于是稍微封装了下

Install

pip install requestspr

Example

from requestspr import Requests, ProxyMode


def twitter():
    """请求推特页面"""
    try:
        return requests.get('https://twitter.com/')
    except Exception as e:
        return e


if __name__ == '__main__':
    # 在开着Clash的情况下

    requests = Requests()

    # 获取代理信息
    print(requests.get_proxies())

    # 默认使用系统代理, 请求成功
    print(twitter())

    # 不使用系统代理,请求超时
    requests.set_proxy_mode(ProxyMode.NoProxy)
    print(twitter())

    # 自行设置代理
    requests.set_proxy_mode(ProxyMode.Static, {'https': '127.0.0.1:7890'})
    print(twitter())

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

requestspr-0.0.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

requestspr-0.0.3-py2.py3-none-any.whl (3.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file requestspr-0.0.3.tar.gz.

File metadata

  • Download URL: requestspr-0.0.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for requestspr-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c9e368ebfd828f21ab90f5a05ec8f879967ea12c44be8d7a713ff2319b68946b
MD5 21d39c418d3809dfcfecdb8e333d6e13
BLAKE2b-256 8f9adea62072d5a85c169dc10d7329259051a416651462e42ea896042ab9f2e1

See more details on using hashes here.

File details

Details for the file requestspr-0.0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: requestspr-0.0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for requestspr-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 11957e9dd8e86c9a0c8fba78d14b309a308ed7108c37a9572133a898af335ce4
MD5 47721ca6e7ab1ff7eae661a0cef62110
BLAKE2b-256 0007a6bf4364d1cc8a16a0a197b36960eb222dc57844e0c70fa601ae76e0ff0a

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