Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- from urllib.request import urlopen
- import pandas as pd
- import csv
- page = open('ABC.html')
- soup = BeautifulSoup(page.read(),'html.parser')
- tables = soup.find_all('table')
- output_rows = []
- for table in tables:
- for table_row in table.findAll('tr'):
- columns = table_row.findAll('td')
- output_row = []
- for column in columns:
- output_row.append(column.text)
- output_rows.append(output_row)
- df = pd.DataFrame(data=output_rows)
- df.to_csv(r'ABC.csv')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement