作者x9060000456 (你好)
看板R_Language
标题[问题]Rselenium 点击右键开启新分页
时间Mon Feb 26 11:29:11 2018
- 问题: 请问如何利用Rselenium控制浏览器点击右键
并按t开启"在新分页开启连结"
[问题类型]:
程式谘询(我想用R 做某件事情,但是我不知道要怎麽用R 写出来)
[问题叙述]:
想开启新分页或新视窗,在新分页或视窗进行爬虫动作。
以下code是参考stack overflow
https://goo.gl/QZn9Q9
,没有出现error,只有执行按右键,但按t这个问题一直
未执行,请各位大大麻烦看一下,谢谢!
[程式范例]:
library(RSelenium)
dr <- remoteDriver(remoteServerAddr = "localhost", port = 4444, browserName =
"chrome")
dr$open()
dr$navigate("
http://www.stackoverflow.com")
# find the Users tab
webElem <- dr$findElement("id", "nav-users")
dr$mouseMoveToLocation(webElement = webElem) # move to the required element
dr$click(2) # right mouse button click
webElem$sendKeysToElement(list(key = "shift", "t"))
[关键字]:
Crawler, RSelenium
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 60.251.111.55
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/R_Language/M.1519615754.A.DA1.html
1F:→ Wush978: 那应该是浏览器的热键,你试试看直接找物件的方法 02/26 12:41
2F:→ Wush978: remoteDriver物件中有没有方法可以切换视窗/页面 02/26 12:42
3F:→ celestialgod: 在新分页开启最简单的方法是 dr$click(1) 02/26 19:04
4F:→ celestialgod: 如果要操作右键出来的选单目前没看到方法 02/26 19:04
5F:→ x9060000456: 谢谢wush大阿~ 可以切换视窗 但主要想要利用点击开启 02/28 20:19
6F:→ x9060000456: 谢谢C大~ 好喔 那我再想想看有没有更好的方法~ 02/28 20:19