title: How to extract a Google link's href from search results with Selenium?
body: <p>Ultimately I am just trying to get the href of the first link to google's search result</p>
  
  <p>The information I need also exists in an 'a' element, but it is stored in a 'data-href' attribute, which I could not figure how to extract the data from (<code>get_attribute('data-href')</code> returns <code>None</code>).</p>
  
  <p>I am using Phantomjs, but have also tried with Firefox web driver</p>
  
  <hr>
  
  <p>The href is displayed in a <code>cite</code> tag in a google search (which can be found by inspecting the small green link text under each link in google search results). </p>
  
  <p>The cite element is apparently found with Selenium, but the text returned (<code>element.text</code>, or <code>get_attribute('innerHTML')</code>, or (<code>text</code>)) is not what is shown in the html.</p>
  
  <p>For instance, there is a cite tag <code>&lt;cite class="_Rm"&gt;www.fcv.org.br/&lt;/cite&gt;</code>, but <code>element.text</code> shows “wikimapia.org/.../Fundação-Cristiano-Varella-Hospital...”</p>
  
  <p>I have tried to retrieve the cite element with <code>by_css_selector</code>, <code>tag_name</code>, <code>class_name</code>, and xpath with the same results.</p>
  
  <pre><code>links = driver.find_elements_by_css_selector('div.g') # div[class="g"]
  link = links[0] # I am looking for the first link in the main links section
  next = link.find_element_by_css_selector('div[class="s"]') # location of cite tag
  nextB = next.find_element_by_tag_name('cite') 
  </code></pre>
  
  <p>div containing cite tag (there is only one in the div)</p>
  
  <pre><code>    &lt;div class="s"&gt;
           &lt;div&gt;
               &lt;div class="f kv _SWb" style="white-space:nowrap"&gt;
                    &lt;cite class="_Rm"&gt;www.fcv.org.br/&lt;/cite&gt;
  </code></pre>