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

>>> from requests_html import AsyncHTMLSession
>>> asession = AsyncHTMLSession()

>>> async def get_pythonorg():
...    r = await asession.get('https://python.org/')

>>> async def get_reddit():
...    r = await asession.get('https://reddit.com/')

>>> async def get_google():
...    r = await asession.get('https://google.com/')

>>> result = session.run(get_pythonorg, get_reddit, get_google)

Example 3: requests-html

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