【发布时间】:2020-08-10 09:28:37
【问题描述】:
我正在尝试从以下网站下载 CSV 和 JSON 数据:https://worldpopulationreview.com/countries/countries-by-gdp/#worldCountries
如何模拟点击csv文件?
import pandas as pd
import requests
from lxml import html,etree
url = "https://worldpopulationreview.com/countries/countries-by-gdp/#worldCountries"
# now I am not sure, how to click csv button of actual website
# also I am not sure how it will download the csv file
# to DOWNLOADS as like when I click the page
我可以抓取网页,但我想学习点击按钮
import pandas as pd
import requests
url = "https://worldpopulationreview.com/countries/countries-by-gdp/#worldCountries"
r = requests.get(url)
df = pd.read_html(r.text)[0]
df.to_csv('data.csv')
【问题讨论】:
标签: python pandas beautifulsoup lxml