semvec/pypi-packages huggingface dataset:
webrequests 1.0.8
A simple wrapper of requests, simple but useful!
License: BSD License

# A simple wrapper of requests, simple but useful!

## Installation
```bash
pip install webrequests
```

## Features
- Random User-Agent
- Try again when request failed
- Download file from an url, with progress bar
- Get a BeautifulSoup from an url

## Usage
```python
from webrequests import WebRequest


# request an url
url = 'http://output.nsfc.gov.cn/captcha/defaultCaptcha'
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
url = 'https://hgdownload.cse.ucsc.edu/goldenPath/hg19/bigZips/hg19.fa.gz'
WebRequest.download(url)
WebRequest.download(url, 'out.jpg', max_try=5, timeout=10)


# request with session
session = requests.session()
resp = WebRequest.get_response('http://www.cip.cc/', session=session)
print(resp.cookies)
print(session.cookies)


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