Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How to find text of h2 tag in python requests-html

# importing the HTMLSession class
from requests_html import HTMLSession
# create the object of the session
session = HTMLSession()
# url of the page
web_page = 'https://www.investopedia.com/terms/s/sample.asp'
# making get request to the webpage
respone = session.get(web_page)
# getting the html of the page
page_html = respone.html
# finding all h2 tags
h2_tags= page_html.find('h2')
# extracting text from all h2 tags
for tag in h2_tags:
    print(tag.text)Copy Code
Comment

PREVIOUS NEXT
Code Example
Python :: Javascript rendering problem in requests-html 
Python :: python run docker interactively subprocess 
Python :: Python NumPy squeeze function Example with axis=1 
Python :: Python NumPy atleast_3d Function Example 2 
Python :: Python NumPy transpose Function Example with use of tuples 
Python :: Python NumPy Shape function example Printing the shape of the multidimensional array 
Python :: how to murj record in django 
Python :: with statement in python 
Python :: tqdm start bar at 
Python :: Python NumPy asfortranarray Function List to an array 
Python :: Python NumPy block Function Example by using simple array 
Python :: add a new field to a Hosted Feature Layer 
Python :: Python NumPy tile Function Example Working with 1D array 
Python :: python json serialize print pretty 
Python :: Python __truediv__ magic method 
Python :: NumPy rot90 Example Rotating Three times 
Python :: python fft 
Python :: NumPy unpackbits Code Unpacked array along axis 1 
Python :: Termfastapi get ip 
Python :: python restrict function parameter type 
Python :: Remove Brackets from List Using the Translate method 
Python :: knn compute_distances_no_loop 
Python :: python selectionsort 
Python :: how to Capture only the ICMP packet. using bpf 
Python :: sqlite basic 
Python :: SQLAlchemy ordering by count on a many to many relationship 
Python :: cyclic rotation python 
Python :: import all csv as individual dataframes python 
Python :: while loop using increment 
Python :: open urls using python grepper 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =