您如何抓取提交表單后自動下載到您的計算機的 xml 檔案?我還沒有看到任何包含來自提交資料的檔案的示例。我一直無法在 python 檔案中找到它。https://docs.python.org/3/library/xml.etree.elementtree.html。任何建議或鏈接將不勝感激。
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.action_chains import ActionChains
url = 'https://oui.doleta.gov/unemploy/claims.asp'
driver = webdriver.Chrome(executable_path=r"C:\Program Files (x86)\chromedriver.exe")
driver.implicitly_wait(10)
driver.get(url)
driver.find_element_by_css_selector('input[name="level"][value="state"]').click()
Select(driver.find_element_by_name('strtdate')).select_by_value('2020')
Select(driver.find_element_by_name('enddate')).select_by_value('2022')
driver.find_element_by_css_selector('input[name="filetype"][value="xml"]').click()
select = Select(driver.find_element_by_id('states'))
# Iterate through and select all states
for opt in select.options:
opt.click()
input('Press ENTER to submit the form')
driver.find_element_by_css_selector('input[name="submit"][value="Submit"]').click()
uj5u.com熱心網友回復:
這篇關于 stackoverflow 的帖子似乎是我正在尋找的方向;如何下載 XML 檔案避免彈出這種型別的檔案可能會通過 ChromeDriver 和 Chrome 在 Python 中使用 Selenium 損害您的計算機
這個鏈接對我的需求幫助最大,所以我會在這里添加它,但是,第一個鏈接也非常有用,所以我想離開它。 如何在 Chrome 中使用 Selenium Python 系結控制檔案的下載
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/368124.html
