Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Explaining async session in requests-html

from requests_html import AsyncHTMLSession
asession = AsyncHTMLSession()

async def get_cnn():
    r = await asession.get('https://edition.cnn.com/')
    title = r.html.find('title')[0].text
    print(title)

async def get_google():
    r = await asession.get('https://google.com/')
    title = r.html.find('title')[0].text
    print(title)

async def get_facebook():
    r = await asession.get('https://facebook.com/')
    title = r.html.find('title')[0].text
    print(title)

asession.run(get_google, get_facebook,get_cnn )Copy Code
Source by www.alixaprodev.com #
 
PREVIOUS NEXT
Tagged: #Explaining #async #session
ADD COMMENT
Topic
Name
4+9 =