Skip to main content

中文的python网络请求库!

Project description

re_it 中文的python网络请求库!

如果程序错了,请报告给534047068@qq.com


快捷输入
输入首字母快速输入,不用切换输入法。
(我用的pycharm)


你可以按照以下步骤使用这个包,并在代码中添加注释以更好地理解其功能和用法: 导入 re_it 模块:from re_it import 请求
创建一个请求对象实例:

我的请求实例 = 请求.我的请求()

使用 添加头部() 方法为请求添加头部信息(有默认请求头):

我的请求实例.添加头部('User-Agent', 'Mozilla/5.0')  # 添加User-Agent头部信息
我的请求实例.添加头部('Content-Type', 'application/json')  # 添加Authorization头部信息

发送 GET 请求并获取响应内容:

网址 = "www.example.com"  # 设置目标网址
响应内容 = 我的请求实例.获取(网址)  # 发送GET请求并获取响应内容
print(响应内容)  # 打印响应内容

发送 POST 请求并获取响应内容:

网址 = "www.example.com"  # 设置目标网址
数据 = "key1=value1&key2=value2"  # 设置POST请求的数据,可选参数
响应内容 = 我的请求实例.提交(网址, 数据)  # 发送POST请求并获取响应内容
print(响应内容)  # 打印响应内容

输出:

<!doctype html>
<html>
<head>
    <title>Example Domain</title>

    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style type="text/css">
    body {
        background-color: #f0f0f2;
        margin: 0;
        padding: 0;
        font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

    }
    div {
        width: 600px;
        margin: 5em auto;
        padding: 2em;
        background-color: #fdfdff;
        border-radius: 0.5em;
        box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
    }
    a:link, a:visited {
        color: #38488f;
        text-decoration: none;
    }
    @media (max-width: 700px) {
        div {
            margin: 0 auto;
            width: auto;
        }
    }
    </style>    
</head>

<body>
<div>
    <h1>Example Domain</h1>
    <p>This domain is for use in illustrative examples in documents. You may use this
    domain in literature without prior coordination or asking for permission.</p>
    <p><a href="https://www.iana.org/domains/example">More information...</a></p>
</div>
</body>
</html>

<!doctype html>
<html>
<head>
    <title>Example Domain</title>

    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style type="text/css">
    body {
        background-color: #f0f0f2;
        margin: 0;
        padding: 0;
        font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

    }
    div {
        width: 600px;
        margin: 5em auto;
        padding: 2em;
        background-color: #fdfdff;
        border-radius: 0.5em;
        box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
    }
    a:link, a:visited {
        color: #38488f;
        text-decoration: none;
    }
    @media (max-width: 700px) {
        div {
            margin: 0 auto;
            width: auto;
        }
    }
    </style>    
</head>

<body>
<div>
    <h1>Example Domain</h1>
    <p>This domain is for use in illustrative examples in documents. You may use this
    domain in literature without prior coordination or asking for permission.</p>
    <p><a href="https://www.iana.org/domains/example">More information...</a></p>
</div>
</body>
</html>

这个网络请求包中的函数有一些可选参数和必选参数。下面是每个函数的参数说明:
添加头部(self, 键, 值) 函数:

必选参数:

  • :要添加到请求头部的键。
  • :要添加到请求头部的值。
    获取(self, 网址) 函数:

必选参数:

  • 网址:目标网址,用于建立连接并发送 GET 请求。
    提交(self, 网址, 数据=None) 函数:

必选参数:

  • 网址:目标网址,用于建立连接并发送 POST 请求。
    可选参数:
  • 数据:POST 请求的数据,使用 URL 编码格式(例如,"key1=value1&key2=value2")。默认值为 None,即没有请求数据。

    所有的函数都是在一个名为 "我的请求" 的类中定义的,并且都需要通过类的实例进行调用(如 请求.函数名())。

需要注意的是,根据具体的使用情况,你可能需要根据需要自定义请求头部信息和请求数据,并根据目标网址发送相应的请求。


version : 1.0.0.0

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

re_it-1.1.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

re_it-1.1.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file re_it-1.1.1.0.tar.gz.

File metadata

  • Download URL: re_it-1.1.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.6

File hashes

Hashes for re_it-1.1.1.0.tar.gz
Algorithm Hash digest
SHA256 6cbffb50b9c80e35194d49b108de262a076108936c82fd60bc99855c4fa4d77b
MD5 84c939e3552144628e5e20392683559c
BLAKE2b-256 e3d6858cfde259643b084a875b581cfc000eb8803b250f33a0c17d62a7857971

See more details on using hashes here.

File details

Details for the file re_it-1.1.1.0-py3-none-any.whl.

File metadata

  • Download URL: re_it-1.1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.6

File hashes

Hashes for re_it-1.1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e2a48cc719111302e7f5c4144b1f809e87f8241e04ade95dc8eee3d09ecdca0
MD5 4dbd25be3748e936d633e77ab70f7923
BLAKE2b-256 6073f93f33f1fd5e94f7289f1f20089ed2433693f1b744b017fbaf230184b0ba

See more details on using hashes here.

Supported by

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