Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
Source by www.alixaprodev.com #
 
PREVIOUS NEXT
Tagged: #Find #element #class #python
ADD COMMENT
Topic
Name
9+9 =