import warnings
warnings.filterwarnings('ignore')

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select 
import time

chromeOptions = webdriver.ChromeOptions() 
chromeOptions.add_argument("--profile-directory=AutoUser")
prefs = {"download.default_directory" : "C:\self_project\covid_project\covid19_project\dataset"} 
chromeOptions.add_experimental_option("prefs",prefs) 
chromedriver = 'C:/Users/LG/dev_python/Webdriver/chromedriver.exe' 
driver_chrome = webdriver.Chrome(executable_path=chromedriver, options=chromeOptions) 


driver_chrome.get("https://jumin.mois.go.kr/ageStatMonth.do") 
time.sleep(1)



download_btn = driver_chrome.find_element_by_id('csvDown')
download_btn.click() 
time.sleep(2)
download_btn.send_keys(Keys.RETURN)  # after this doesn't work....
time.sleep(5)

district_city = driver_chrome.find_element_by_name("sltOrgLvl1")
district_city_dropdown = Select(district_city) 
district_city_dropdown.select_by_index('1') 
time.sleep(1)

driver_chrome.close()

这张照片截取的照片停止了...

enter image description here

我想继续底部的代码(district_city部分)或关闭网站.

推荐答案

试着换掉你的衣服

download_btn.send_keys(Keys.RETURN)  # after this doesn't work....

具有

driver_chrome.switch_to.alert.accept()

Python相关问答推荐

使用Keras的线性回归参数估计

Pandas 第二小值有条件

对某些列的总数进行民意调查,但不单独列出每列

PywinAuto在Windows 11上引发了Memory错误,但在Windows 10上未引发

抓取rotowire MLB球员新闻并使用Python形成表格

在Wayland上使用setCellWidget时,try 编辑QTable Widget中的单元格时,PyQt 6崩溃

如何在Python中并行化以下搜索?

用NumPy优化a[i] = a[i-1]*b[i] + c[i]的迭代计算

如何请求使用Python将文件下载到带有登录名的门户网站?

我对我应该做什么以及我如何做感到困惑'

梯度下降:简化要素集的运行时间比原始要素集长

Pandas计数符合某些条件的特定列的数量

在pandas数据框中计算相对体积比指标,并添加指标值作为新列

在二维NumPy数组中,如何 Select 内部数组的第一个和第二个元素?这可以通过索引来实现吗?

使用类型提示进行类型转换

Python—在嵌套列表中添加相同索引的元素,然后计算平均值

Pythonquests.get(Url)返回Colab中的空内容

时长超过24小时如何从Excel导入时长数据

多个布尔条件的`jax.lax.cond`等效项

将多行数据循环到嵌套框架中的单行