title: How can I download a csv file from a button in rvest [R]?
body: <p>I am new to rvest and I need to write a script that downloads a csv file from a website. The website is <a href="http://phoible.org/inventories" rel="nofollow">http://phoible.org/inventories</a>.</p>
  
  <p>At the right hand side, there is drop-down button that gives the option to download the data in several formats (including the csv file I am interested in). First, I inspected the css content and I found out that the button I am interested in has the following css:</p>
  
  <pre><code>&lt;a href="#" id="dt-dl-csv" onclick="document.location.href = CLLD.DataTable.current_url(&amp;quot;Inventories&amp;quot;, &amp;quot;csv&amp;quot;); return false;"&gt;csv&lt;/a&gt;
  </code></pre>
  
  <p>Then I tried the following code:</p>
  
  <pre><code>p = html_session("http://www.phoible.org/inventories")
  csv_link = p %&gt;% 
  html_nodes("a") %&gt;% 
  html_attr("onclick")
  </code></pre>
  
  <p>However, I get the following line:</p>
  
  <pre><code>[1] NA NA NA NA NA NA NA NA NA NA NA NA
  </code></pre>
  
  <p>I need to automatically download the csv file to my computer. I would really appreciate any help. Thank you in advance.</p>