Advertisement
betauli

Untitled

Jun 28th, 2020
1,660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. from bs4 import BeautifulSoup
  2. from urllib.request import urlopen
  3. import pandas as pd
  4.  
  5. page = open('ABC.html')
  6.  
  7. soup = BeautifulSoup(page.read(),'html.parser')
  8.  
  9. tables = soup.find_all('table')
  10.  
  11. output_rows = []
  12.  
  13. for table in tables:
  14.     for table_row in table.findAll('tr'):
  15.         columns = table_row.findAll('td')
  16.         output_row = []
  17.         for column in columns:
  18.             output_row.append(column.text)
  19.         output_rows.append(output_row)
  20.  
  21. df = pd.DataFrame(data=output_rows)
  22.  
  23. print(df)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement