Skip to main content

No project description provided

Project description

zdppy_requests

基于requests二开的HTTP请求库,无任何第三方依赖,可独立使用,不受开源框架迭代的影响。

使用示例

安装

pip install zdppy_requests

获取网页源码

import zdppy_requests as zr

response = zr.get("https://www.baidu.com/")
print(response.status_code)
print(response.text)

创建Mapping
import zdppy_requests as zr
from zdppy_requests.auth import HTTPBasicAuth

url = "http://localhost:9200"
body = {
  "mappings": {
    "properties": {
      "name": {
        "type": "text"
      },
      "price": {
        "type": "double"
      },
      "author": {
        "type": "text"
      },
      "pub_date": {
        "type": "date"
      }
    }
  }
}
index = "books"
auth = HTTPBasicAuth('elastic','zhangdapeng520')

response = zr.put(f"{url}/{index}", json=body, auth=auth)
print(response.status_code)
print(response.text)

查询Mapping

import zdppy_requests as zr
from zdppy_requests.auth import HTTPBasicAuth

url = "http://localhost:9200"
index = "books/_mapping?pretty"
auth = HTTPBasicAuth('elastic','zhangdapeng520')
target = f"{url}/{index}"

response = zr.get(target, auth=auth)
print(response.status_code)
print(response.text)

删除Mapping

import zdppy_requests as zr
from zdppy_requests.auth import HTTPBasicAuth

url = "http://localhost:9200"
index = "books"
auth = HTTPBasicAuth('elastic','zhangdapeng520')
target = f"{url}/{index}"

response = zr.delete(target, auth=auth)
print(response.status_code)
print(response.text)

根据ID新增数据

import zdppy_requests as zr
from zdppy_requests.auth import HTTPBasicAuth

url = "http://localhost:9200"
index = "books/_doc"
did = "1"
auth = HTTPBasicAuth('elastic','zhangdapeng520')
target = f"{url}/{index}/{did}"
body = {
	"name": "《JavaScript全栈开发实战》",
	"author": "张大鹏",
	"price": 123,
	"pub_date": "2019-12-12"
}

response = zr.put(target, json=body, auth=auth)
print(response.status_code)
print(response.text)

根据ID查询图书

import zdppy_requests as zr
from zdppy_requests.auth import HTTPBasicAuth

url = "http://localhost:9200"
index = "books/_doc"
did = "1"
auth = HTTPBasicAuth('elastic','zhangdapeng520')
target = f"{url}/{index}/{did}"

response = zr.get(target, auth=auth)
print(response.status_code)
print(response.text)

根据ID删除图书

import zdppy_requests as zr
from zdppy_requests.auth import HTTPBasicAuth

url = "http://localhost:9200"
index = "books/_doc"
did = "1"
auth = HTTPBasicAuth('elastic','zhangdapeng520')
target = f"{url}/{index}/{did}"

response = zr.delete(target, auth=auth)
print(response.status_code)
print(response.text)

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

zdppy_requests-0.1.3.tar.gz (387.9 kB view details)

Uploaded Source

Built Distribution

zdppy_requests-0.1.3-py3-none-any.whl (413.5 kB view details)

Uploaded Python 3

File details

Details for the file zdppy_requests-0.1.3.tar.gz.

File metadata

  • Download URL: zdppy_requests-0.1.3.tar.gz
  • Upload date:
  • Size: 387.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.13 Linux/5.15.0-58-generic

File hashes

Hashes for zdppy_requests-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f078983bd964d842f97afa452ee1417f2be61cc539899dbb4dd8560b8e46c039
MD5 128a9338d12981d58a3443b2569c7d1b
BLAKE2b-256 3e8008fe2a87f704a5ce1bfd17e396272ce9830bee4aa06b159bba3e23eab34a

See more details on using hashes here.

File details

Details for the file zdppy_requests-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: zdppy_requests-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 413.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.13 Linux/5.15.0-58-generic

File hashes

Hashes for zdppy_requests-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a9fb9be97d379c6ca6f35c4a6a118326c418777f8d2a3c8b2f046218145c2731
MD5 b1179b160bd25b6650359e7570e15847
BLAKE2b-256 a62f7835586867d1286da95fc4c1371e244b4a4940ddc1de359ee1e8db15abcc

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