python selenium 点击链接_Python Selenium创建循环以单击页面上的链接,然后在每个新页面上按按钮...

这篇博客探讨了如何使用Python的Selenium库在网页上点击用户名链接,然后在新页面上找到并点击关注按钮。作者遇到了循环中元素过期的问题,并分享了解决方案,即使用显式等待来定位并点击每个链接,避免StaleElement异常。
摘要由CSDN通过智能技术生成

I'm fairly new to Python and Selenium, but starting to pick it up. I've been googling how to solve this coding issue, but can't find the exact solution.

What I'm trying to accomplish is click all of the username links on a page, click the follow button on the page that I'm taken to, then return to the original page and do the same for rest of the username links.

Basically, I want to create a loop that does this:

click on the first username

click on the follow button

go back to the previous page

click on the second username

click on the follow button

go back to the previous page

ETC..... through each link

Here is my current code and what I've tried so far:

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

browser = webdriver.Firefox()</

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值