[問題] Rselenium 點擊右鍵開啟新分頁

看板R_Language作者 (你好)時間7年前 (2018/02/26 11:29), 編輯推噓0(006)
留言6則, 3人參與, 7年前最新討論串1/1
- 問題: 請問如何利用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://www.ptt.cc/bbs/R_Language/M.1519615754.A.DA1.html

02/26 12:41, 7年前 , 1F
那應該是瀏覽器的熱鍵,你試試看直接找物件的方法
02/26 12:41, 1F

02/26 12:42, 7年前 , 2F
remoteDriver物件中有沒有方法可以切換視窗/頁面
02/26 12:42, 2F

02/26 19:04, 7年前 , 3F
在新分頁開啟最簡單的方法是 dr$click(1)
02/26 19:04, 3F

02/26 19:04, 7年前 , 4F
如果要操作右鍵出來的選單目前沒看到方法
02/26 19:04, 4F

02/28 20:19, 7年前 , 5F
謝謝wush大阿~ 可以切換視窗 但主要想要利用點擊開啟
02/28 20:19, 5F

02/28 20:19, 7年前 , 6F
謝謝C大~ 好喔 那我再想想看有沒有更好的方法~
02/28 20:19, 6F
文章代碼(AID): #1QatyAsX (R_Language)
文章代碼(AID): #1QatyAsX (R_Language)