Answers for "Find element with class name in requests-html python"

0

Find element with class name in requests-html python

# importing the HTMLSession class
from requests_html import HTMLSession
# create the object of the session
session = HTMLSession()
# url of the page
web_page = 'https://webscraper.io/'
# making get request to the webpage
respone = session.get(web_page)
# getting the html of the page
page_html = respone.html
# finding element with class name 'embedded-video'
video_frame= page_html.find('.embedded-video')
# get all atributes
video_attrs = video_frame[0].attrs
# find the url using dict.get()
video_url = video_attrs['src']
# printing element
print(video_url)Copy Code
Posted by: Guest on April-21-2022

Code answers related to "Find element with class name in requests-html python"

Python Answers by Framework

Browse Popular Code Answers by Language