Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

grab element based on text from html page in 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 elements based on text
p_tag_with_text= page_html.find('p',containing='web data extraction')
# printing the element
print(p_tag_with_text)
 Copy Code
Source by www.alixaprodev.com #
 
PREVIOUS NEXT
Tagged: #grab #element #based #text #html #page #python
ADD COMMENT
Topic
Name
1+5 =