title: Web scraping for Google Ads using python and beautifulsoup
body: <p>I am trying to scrape for  Google search results that have the "Ad" in the right, ie scraping for Google ad links from search results.
  I have the following script, where I am stuck at soup.select() step. I am not sure which selectors to use... Any help is appreciated in advance
  inspect element below:
  <a href="https://i.stack.imgur.com/1xGIB.png" rel="nofollow noreferrer">screen capture of inspect element</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>#! python3
  #!usr/bin/env python3
  
  import  requests, bs4, webbrowser
  
  #Get Google search results
  ui_search = input("Search google: ")
  print('Googling...') #display text while downloading
  if len(ui_search)&gt;1:
      res = requests.get('https://google.com/search?q=' + ' '.join(ui_search))
      res.raise_for_status()
  
  #Retrieve the results with ads and open them.
  soup = bs4.BeautifulSoup(res.text, 'html.parser')
  
  #Open a browser tab for each result
  linkElems = soup.select('.V0MxL a')
  linkElems2 = soup.select('.ad_cclk a')
  numOpen = min(5, len(linkElems))
  print(numOpen)
  for i in range(numOpen):
      print(linkElems[i].get('href'))
      webbrowser.open('http://google.com' +linkElems[i].get('href'))</code></pre>
  </div>
  </div>
  </p>
  
  <p>Code for similar code without specifying for ads:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>#! python3
  #lucky.py - Opens several Google search results.
  
  import requests
  import sys
  import webbrowser
  import bs4
  
  ui_search = input("Search google: ")
  print('Googling...') #display text while downloading
  if len(sys.argv) &gt; 1:
      res = requests.get('http://google.com/search?q=' + ' '.join(sys.argv[1:]))
  elif len(ui_search) &gt; 1:
      res = requests.get('http://google.com/search?q=' + ' '.join(ui_search))
      res.raise_for_status()
  
  #Retrieve top search result links.
  soup = bs4.BeautifulSoup(res.text, 'html.parser')
  #type(soup)
  #Open a browser tab for each result
  linkElems = soup.select('.r a')
  numOpen = min(5, len(linkElems))
  for i in range(numOpen):
      print(linkElems[i])
     # webbrowser.open('http://google.com' + linkElems[i].get('href'))</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>Example results:
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/qH3XF.png" rel="nofollow noreferrer">enter image description here</a></p>