title: Which selector to write in rvest in R to extract information from google websearch?
body: <p>I am trying to download content of google websearch that is in 
  <code>&lt;h3 class="r"&gt;</code> as on image below</p>
  
  <p>I've tried to write such selectors in R, using <code>rvest</code> package but with no result.
  Anyone knows how should the selector look like?</p>
  
  <pre><code>&gt; library(rvest)
  &gt; 
  &gt; googleContent &lt;- html("https://www.google.pl/#q=wiadomosci") %&gt;% 
  +    html_nodes( "h3[class=r]" )
  &gt; googleContent
  list()
  attr(,"class")
  [1] "XMLNodeSet"
  &gt; googleContent &lt;- html("https://www.google.pl/#q=wiadomosci") %&gt;% 
  +    html_nodes( "h3.r" )
  &gt; googleContent
  list()
  attr(,"class")
  [1] "XMLNodeSet"
  </code></pre>
  
  <p>I've tried other packages but I don't like the messy code...
  (changed code from this <a href="https://tonybreyal.wordpress.com/2011/11/07/web-scraping-google-urls/" rel="nofollow noreferrer">article</a>)</p>
  
  <pre><code>&gt; # load packages
  &gt; library(RCurl)
  &gt; library(XML)
  &gt; library(dplyr)
  &gt; get_google_page_urls &lt;- function(u) {
  +    # read in page contents
  +    html &lt;- getURL(u)
  +    
  +    # parse HTML into tree structure
  +    doc &lt;- htmlParse(html)
  +    
  +    # extract url nodes using XPath. Originally I had used "//a[@href][@class='l']" until the google code change.
  +    links &lt;- xpathApply(doc, "//h3//a[@href]", function(x) xmlAttrs(x)[[1]])
  +    
  +    # free doc from memory
  +    free(doc)
  +    
  +    # ensure urls start with "http" to avoid google references to the search page
  +    links &lt;- grep("http://", links, fixed = TRUE, value=TRUE)
  +    return(links)
  + }
  &gt; 
  &gt; u &lt;- "http://www.google.pl/search?aq=f&amp;gcx=w&amp;sourceid=chrome&amp;ie=UTF-8&amp;q=wiadomosci"
  &gt;  get_google_page_urls(u) %&gt;% grep( pattern = "/url", value = TRUE) %&gt;% strsplit( "?q=") %&gt;%
  +    lapply( function(element){ strsplit( element[2], ".pl" )[[1]][1] } ) %&gt;%
  +    unlist() %&gt;% paste0(".pl") %&gt;% unique()
  [1] "http://wiadomosci.onet.pl"   "http://www.tvn24.pl"         "http://tvnwarszawa.tvn24.pl"
  [4] "http://wiadomosci.wp.pl"     "http://warszawa.gazeta.pl"   "http://wiadomosci.gazeta.pl"
  [7] "http://wiadomosci.tvp.pl"    "http://www.se.pl"   
  </code></pre>
  
  <p>Does this might help somehow?
  I don't understand this functionality because the documentation is very poor</p>
  
  <pre><code>search &lt;- html_form(html("https://www.google.com"))[[1]]
  
  
  set_values(search, q = "My little pony")
  </code></pre>
  
  <p><img src="https://i.imgur.com/v9PZiHL.jpg" alt="example"></p>