Python中文
首页
教程
问答
标签
搜索
登录
注册
无法使用selenium python定位元素
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>对不起,如果我的问题格式是错误的,因为我是新的编程和StackOverFlow。我无法使用类或任何其他方法找到下载按钮。目前正在尝试使用xpath解决问题,但我听说xpath不是可靠的方法。我正试图从wikiloc网站上下载特定位置内的所有轨道路径。登录时可能会出现问题,因为我可能在抓取时未登录。顺便说一句,我主要使用谷歌colab。我的代码如下:</p> <pre><code>driver.get('https://www.wikiloc.com/wikiloc/start.do') driver.find_element_by_name('email').send_keys('testacount852') driver.find_element_by_name('password').send_keys('49Vchu4njDrrT7.') driver.find_element_by_id('submit-button').click() time.sleep(10) driver.get("https://www.wikiloc.com/trails/outdoor/france/brittany") links = [] temp_links = [] names = [] temp_names = [] for _ in range(4): temp = driver.find_elements_by_css_selector('a.trail-title.dont-break-out') temp_links = [x.get_attribute('href') for x in temp] temp_names = [x.text for x in temp] links = links+temp_links names = names+temp_names try: driver.find_element_by_class_name('next').click() time.sleep(2) except: break for link in links: driver.get(link) driver.find_element_by_id('download-button').click() time.sleep(4) driver.find_element_by_class_name('active').click() time.sleep(4) driver.find_element_by_xpath("/html/body/main/div/div[2]/div/div[1]/div/div[2]/div/div[2]/form/div[2]/input").click() time.sleep(4) df['Names'] = pd.Series(names) df['Links'] = pd.Series(links) df.to_csv('test1.csv') driver.close() </code></pre> <p>这是指向我的凭据的链接 [1] :<a href="https://i.stack.imgur.com/HZ6bZ.png" rel="nofollow noreferrer">https://i.stack.imgur.com/HZ6bZ.png</a></p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>好吧,我找到问题了。是验证码破坏了它。我无法登录,下载按钮(xpath)在我登录之前不可用。感谢各位特别帮助我@ShawnRamirez指出验证码</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
无法使用Django/mongoengine连接到MongoDB(身份验证失败)
5 回答
无法使用Django\u mssql\u后端迁移到外部hos
1 回答
无法使用Django&Python3.4连接到MySql
6 回答
无法使用Django+nginx上载媒体文件
2 回答
无法使用Django1.6导入名称模式
7 回答
无法使用Django1.7和mongodb登录管理站点
9 回答
无法使用Djangoadmin创建项目,进程使用了错误的路径,因为我事先安装了错误的Python
2 回答
无法使用Djangockedi验证CBV中的字段
2 回答
无法使用Djangocketditor上载图像(错误400)
3 回答
无法使用Djangocron进行函数调用
1 回答
无法使用Djangofiler djang上载文件
1 回答
无法使用Djangokronos
4 回答
无法使用Djangomssql provid
6 回答
无法使用Djangomssql连接到带有Django 1.11的MS SQL Server 2016
1 回答
无法使用Djangomssq迁移Django数据库
3 回答
无法使用Djangonox创建用户
7 回答
无法使用Djangopyodb从Django查询SQL Server
4 回答
无法使用Djangopython3ldap连接到ldap
4 回答
无法使用Djangoredis连接到redis
5 回答
无法使用Django中的FK创建新表
7 回答