title: Web Scraping Linkedin Profiles: Cannot pick all links
body: <p>Following is the code being used:</p>
  
  <pre><code>linkedin_urls = driver.find_elements_by_class_name('r')
  
  sub = 'linkedin.com'
  
  for linkedin_url in linkedin_urls:
      tag = linkedin_url.find_element_by_tag_name('a')
      URL = tag.get_attribute('href')
  
      if sub in URL:
         try:
            driver.get(URL)
            sleep(5)
            driver.back()
            driver.get(URL)
         except:
            pass
  </code></pre>
  
  <ul>
  <li><em>Following is the error i get:</em></li>
  </ul>
  
  <blockquote>
    <p>Traceback (most recent call last):</p>
    
    <p>File "", line 25, in 
        tag = linkedin_url.find_element_by_tag_name('a')</p>
    
    <p>File
    "C:\Users\deepankar.garg\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\remote\webelement.py",
    line 305, in find_element_by_tag_name
        return self.find_element(by=By.TAG_NAME, value=name)</p>
    
    <p>File
    "C:\Users\deepankar.garg\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\remote\webelement.py",
    line 659, in find_element
        {"using": by, "value": value})['value']</p>
    
    <p>File
    "C:\Users\deepankar.garg\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\remote\webelement.py",
    line 633, in _execute
        return self._parent.execute(command, params)</p>
    
    <p>File
    "C:\Users\deepankar.garg\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\remote\webdriver.py",
    line 321, in execute
        self.error_handler.check_response(response)</p>
    
    <p>File
    "C:\Users\deepankar.garg\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\remote\errorhandler.py",
    line 242, in check_response
        raise exception_class(message, screen, stacktrace)</p>
    
    <p>StaleElementReferenceException: stale element reference: element is
    not attached to the page document   (Session info:
    chrome=79.0.3945.79)</p>
  </blockquote>
  
  <p><strong>Following is the output before <em>IF</em> condition:</strong></p>
  
  <p><a href="https://www.linkedin.com/in/elena-grewal" rel="nofollow noreferrer">https://www.linkedin.com/in/elena-grewal</a></p>
  
  <p><a href="https://www.quora.com/What-is-the-difference-between-Data-Science-and-Analytics" rel="nofollow noreferrer">https://www.quora.com/What-is-the-difference-between-Data-Science-and-Analytics</a></p>
  
  <p><a href="https://www.edureka.co/blog/what-is-data-science/" rel="nofollow noreferrer">https://www.edureka.co/blog/what-is-data-science/</a></p>
  
  <p><strong>Following is the output after <em>IF</em> condition:</strong></p>
  
  <p><a href="https://www.linkedin.com/in/elena-grewal" rel="nofollow noreferrer">https://www.linkedin.com/in/elena-grewal</a></p>
  
  <p><a href="https://in.linkedin.com/in/bsatya" rel="nofollow noreferrer">https://in.linkedin.com/in/bsatya</a></p>
  
  <p><a href="https://www.linkedin.com/in/kylemckiou" rel="nofollow noreferrer">https://www.linkedin.com/in/kylemckiou</a></p>
  
  <p>I know what the error means, but i do not know how to resolve it. I just wish to open each link in the "if" (true) condition in a separate web browser. The links present in the above "after IF" condition is what i wish to open in each tab. </p>
  
  <p>Any help would be really appreciated! </p>