Skip to main content

A simple wrapper of requests, easy but useful!

Project description

A simple wrapper of requests, easy but useful!

Installation

pip install webrequests

Features

  • Random User-Agent automatic
  • Try again when request failed
  • Download file from an URL
  • Get a soup from an URL

Usage

from webrequests import WebRequest


url = 'http://output.nsfc.gov.cn/captcha/defaultCaptcha'

# request an url
resp = WebRequest.get_response(url)
resp = WebRequest.get_response(url, method='POST', max_try=5, timeout=5)
print(resp.headers)


# download file from an url
WebRequest.download(url, 'out.jpg')
WebRequest.download(url, 'out.jpg', max_try=5, timeout=10)


# request with session
import requests

session = requests.session()
resp = WebRequest.get_response(url, session=session)
print(resp.cookies)
print(session.cookies)


# get a soup
url = 'http://www.cip.cc/'
soup = WebRequest.get_soup(url)
print(soup.select_one('.kq-well pre').text.strip())

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

webrequests-1.0.2.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file webrequests-1.0.2.tar.gz.

File metadata

  • Download URL: webrequests-1.0.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8

File hashes

Hashes for webrequests-1.0.2.tar.gz
Algorithm Hash digest
SHA256 103cb104f545eddb5023ad5cbfed40517d51a9f58cb800ccc5c7a153d5ebd4c7
MD5 4e9c95c763a317476be72eca66ba6261
BLAKE2b-256 8255b36bdf24f29eed111f44a9a54bcf1808dd524ca91a45b49a0d3e5c6300cc

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