request html python code example

Example 1: python request get html code

# from http://zetcode.com/python/requests/
import requests as req

resp = req.get("http://www.webcode.me")

print(resp.text)

Example 2: requests-html

>>> about.attrs
{'id': 'about', 'class': ('tier-1', 'element-1'), 'aria-haspopup': 'true'}

Example 3: requests-html

>>> from requests_html import HTMLSession
>>> session = HTMLSession()

>>> r = session.get('https://python.org/')

Example 4: requests-html

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

Tags:

Html Example