title: extracting href from <a> beautiful soup
body: <p>I'm trying to extract a link from a google search result. Inspect element tells me that the section I am interested in has "class = r". The first result looks like this:</p>
  
  <pre><code>&lt;h3 class="r" original_target="https://en.wikipedia.org/wiki/chocolate" style="display: inline-block;"&gt;
      &lt;a href="https://en.wikipedia.org/wiki/Chocolate" 
         ping="/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;url=https://en.wikipedia.org/wiki/Chocolate&amp;amp;ved=0ahUKEwjW6tTC8LXZAhXDjpQKHSXSClIQFgheMAM" 
         saprocessedanchor="true"&gt;
          Chocolate - Wikipedia
      &lt;/a&gt;
  &lt;/h3&gt;
  </code></pre>
  
  <p>To extract the "href" I do:</p>
  
  <pre><code>import bs4, requests
  res = requests.get('https://www.google.com/search?q=chocolate')
  googleSoup = bs4.BeautifulSoup(res.text, "html.parser")
  elements= googleSoup.select(".r a")
  elements[0].get("href")
  </code></pre>
  
  <p>But I unexpectedly get:</p>
  
  <pre><code>'/url?q=https://en.wikipedia.org/wiki/Chocolate&amp;sa=U&amp;ved=0ahUKEwjHjrmc_7XZAhUME5QKHSOCAW8QFggWMAA&amp;usg=AOvVaw03f1l4EU9fYd'
  </code></pre>
  
  <p>Where I wanted:</p>
  
  <p><code>"https://en.wikipedia.org/wiki/Chocolate"</code></p>
  
  <p>The attribute "ping" seems to be confusing it. Any ideas?</p>