2017-03-17 19 views
0

我跟着:How to get google search results如何取消Google的第一個鏈接的描述?

和它的作品,但我會放棄第一個鏈接的描述,谷歌的回報,爲CRAN關鍵字是:

<span class="st"><em>CRAN</em> is a network of ftp and web servers around the world that store identical, up-to-date, versions of code and documentation for R. Please use the <em>CRAN</em>&nbsp;...</span> 

,但我不知道什麼是span節在這裏,請提供解決方案,而無需使用RSelenium

回答

1

使用rvest

library(rvest) 

baseUrl <- 'https://www.google.it/search?q=' 

query = 'cran' 
url <- paste0(baseUrl, query) 


read_html(url) %>% 
    html_nodes('.st') %>% 
    # This select only the first result, change number to select another reusult 
    # or comment it to get all first page results 
    '['(2) %>% 
    html_text()