티스토리 뷰
728x90
pip install lxml html5lib beautifulsoup4
import pandas as pd
url = 'https://en.wikipedia.org/wiki/History_of_Python'
dfs = pd.read_html(url)
print(len(dfs))
print(dfs[0]['Version'])
print(dfs[0]['Release date'])
# Load pandas
import pandas as pd
# Webpage url
url = 'https://en.wikipedia.org/wiki/History_of_Python'
# Extract tables
dfs = pd.read_html(url)
# Get first table
df = dfs[0]
# Extract columns
df2 = df[['Version','Release date']]
print(df2)
# Write to excel
df2.to_excel('python.xlsx')
https://pythonbasics.org/pandas-web-scraping/
Pandas Web Scraping - Python Tutorial
Pandas makes it easy to scrape a table ( tag) on a web page. After obtaining it as a DataFrame, it is of course possible to do various processing and save it as an Excel file or csv file. In this article you’ll learn how to extract a table from any webpa
pythonbasics.org
728x90
'공부' 카테고리의 다른 글
[kotlin] public static void main (0) | 2022.08.18 |
---|---|
[gradle] jar > archive contains more than 65535 entries. (0) | 2022.08.17 |
[Scala] SparkSession.conf(String, Any) (0) | 2022.08.13 |
[kotlin] map -> flatMap (0) | 2022.08.11 |
Spring Webflux + JDBC(혹은 blocking call) 핸들링 방법 (0) | 2022.08.11 |
댓글