library(xml2)
require(RSelenium)
# open the remote driver
fprof <- makeFirefoxProfile(list(browser.download.dir = "C:/temp"
, browser.download.folderList = 2L
, browser.download.manager.showWhenStarting = FALSE
, browser.helperApps.neverAsk.saveToDisk = "application/zip"))
remDr <- remoteDriver(browserName = "firefox",remoteServerAddr = "192.168.99.100",port = 4445L,extraCapabilities = fprof)
remDr$open(silent = TRUE)
#
# go to the webpage
remDr$navigate("https://www.expedia.co.uk/Guangzhou-Hotels-Blog-Hotel-Guangzhou.h8282429.Hotel-Information")
# create R objects from the website elements
guestreview <- remDr$findElement(using = 'id', value = "tab-reviews")
Nextbtn <- remDr$findElement(using = 'class', value = "pagination-next")
# click the guest review button
remDr$screenshot(display = TRUE)
# get the output
reviews <- remDr$findElement(using = "class", value="translate-text")
reviews <- reviews$getElementText()[[1]] # extract the actual text string
&#13;
嗨,我正在使用Rselenium从网站expedia中搜索用户评论。我按照本教程 https://rawgit.com/petrkeil/Blog/master/2017_08_15_Web_scraping/web_scraping.html 但我在尝试点击“访客评论”按钮时收到错误 你可以帮助我找到我的错误我已经坚持这个问题超过一个星期
Selenium message:Element is not clickable at point (264, 28.333328247070312). Other element would receive the click: <div class="modal-wrap uitk-tooltip-container modal-dismiss active" id="eds-modal"></div>
答案 0 :(得分:1)
fprof <- makeFirefoxProfile(list(browser.download.dir = "C:/temp"
, browser.download.folderList = 2L
, browser.download.manager.showWhenStarting = FALSE
, browser.helperApps.neverAsk.saveToDisk = "application/zip"))
remDr <- remoteDriver(browserName = "firefox",remoteServerAddr = "192.168.99.100",port = 4445L,extraCapabilities = fprof)
remDr$open(silent = TRUE)
#
# go to the webpage
remDr$navigate("https://www.expedia.co.uk/Dalian-City-Center-Hotels-Grand-Continent-International-Hotel.h17262978.Hotel-Information")
#close popup window
remDr$screenshot(display = TRUE)
closebt <- remDr$findElement(using = "id", "modalCloseButton")
closebt$clickElement()
remDr$screenshot(display = TRUE)# just to see if the popup windows is closed
# create R objects from the website elements
guestreview <- remDr$findElement(using = 'id', value = "tab-reviews")
Nextbtn <- remDr$findElement(using = 'class', value = "pagination-next")
# click the guest review button
guestreview$clickElement()
# get the output
out <- remDr$findElement(using = "class", value="translate-text")
out <- out$getElementText()[[1]] # extract the actual text string
强调文字这就是我关闭弹出窗口的方式
答案 1 :(得分:0)
首次进入Expedia网站时,会出现一个弹出窗口,要求您输入入住日期。
此弹出窗口阻止您在页面上执行操作。您必须添加代码来处理此弹出窗口并最终关闭它然后才能继续。