我想学习如何使用 python 下载过去十年的 CSV 文件。我认为这会有所帮助。
https://www.usgovernmentspending.com/compare_state_debt
我的尝试涉及请求和熊猫。
我想学习如何使用 python 下载过去十年的 CSV 文件。我认为这会有所帮助。
https://www.usgovernmentspending.com/compare_state_debt
我的尝试涉及请求和熊猫。
问题已解决我设法使用硒解决了它。
通过执行以下操作:
from selenium import webdriver # allow launching browser
# Opening in incognito
driver_option = webdriver.ChromeOptions()
#driver_option.add_argument(" — incognito")
chromedriver_path = '# Write your path here' # Change this to your own chromedriver path!
# Creating a webdriver.
def create_webdriver():
return webdriver.Chrome(executable_path=chromedriver_path, options=driver_option)
URL = ""
browser.get(url)
# Clicking the button.
elem1 = browser.find_element_by_link_text("download file")
# Clicking the button.
elem1.click()
直到 2020 年,我都将之前的代码循环放入了一个循环中,并且我得到了 CSV 格式的所有文件