Step # 1: Convert to Pandas dataframe
Pandas — it is a Python library used to manipulate tables. Our first step is to save the table from the web page in a Pandas dataframe. The read_html ()
function returns a list of data frames, each element representing a table on a web page. Here we assume that the web page contains one table.
|
Exit
0 1 2 3 4 0 ROLL_NO NAME ADDRESS PHONE AGE 1 1 RAM DELHI 9455123451 18 2 2 RAMESH GURGAON 9652431543 18 3 3 SUJIT ROHTAK 9156253131 20 4 4 SURESH DELHI 9156768971 18
Step # 2: Storing the data frame Excel
For this we use the Pandas function, passing in the filename as a parameter.
|
Output:
In case of multiple tables on a web page, we can change the index number from 0 to the number of the required table.