python requests-html code example

Example 1: python requests

>>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
>>> r.status_code
200
>>> r.headers['content-type']
'application/json; charset=utf8'
>>> r.encoding
'utf-8'
>>> r.text
u'{"type":"User"...'
>>> r.json()
{u'private_gists': 419, u'total_private_repos': 77, ...}

Example 2: requests-html

>>> print(about.text)
About
Applications
Quotes
Getting Started
Help
Python Brochure

Example 3: requests-html

>>> r.html.search('Python is a {} language')[0]
programming

Example 4: requests-html

>>> about = r.html.find('#about', first=True)

Tags:

Html Example