r - 退出 R 中的函数
问题描述
我正在编写一个从 R 中的 Gmail 帐户中提取用户名的网络抓取项目。我编写了一个代码,其中 e 是用户名列表。函数 f 包含用于抓取的代码 & for 循环将索引传递给函数 f,使用索引我们将用户名发送到远程浏览器,然后单击下一步。如果我的用户名是正确的控制将转到下一页。如果错了,我会得到一行用户名错误。如果我的函数在用户名中找到错误元素,那么我想退出函数并转到 for 循环。我怎样才能在 R 中做到这一点?有没有其他方法可以获得我的预期输出?
代码-
e = list of Gmail username
f <- function(i){
#Username
u <- remDr$findElement("css","value")
u$sendKeysToElement(list(e[i]))
#click next
n <- remDr$fundElement("css","value")
n$sendKeysToElement(list("Enter"))
##if user name is wrong exit function & go to for loop
check <- tryCatch(remDr$findElemnt("css","value"),
error = function(e) print("error"))
if(typeof(check) =="S4"){
##what to do to exit function & go to for loop
}else{
print("continue")
}
for(i in sew(1,4))
{
f(i)
}
解决方案
推荐阅读
- agora.io - Agora Channels : 如何获取 Agora RTC 中直播的频道列表?
- hikaricp - 来自 HikariCP 的初始连接
- android - 构建自定义布局应用程序时出现黑屏
- python-3.x - 难以使用 Zenpy 更新宏,要么我缺少位置参数,要么宏对象不包含“更新”属性
- node.js - mongo过滤器添加排序选项
- unity3d - 2D 弹跳球
- amazon-web-services - 如何通过 Lake Formation 与另一个帐户共享我的 Glue 目录?
- javascript - 如何使用 Javascript 添加嵌入式 YouTube 视频的视频标题?
- reactjs - Chakra UI 自定义单选按钮点击时没有任何反应
- c++ - 为什么我的 TGA 文件以数字代码打开而不是显示我的图像?