title: scrape Reference number from a web site
body: <p>I create a python script that gets data after entering the Reference number. that part is done.</p>
  <p>Now I'm trying to get the Reference number for each capital from <a href="https://register.fca.org.uk/s/search?q=capital&amp;type=Companies" rel="nofollow noreferrer">https://register.fca.org.uk/s/search?q=capital&amp;type=Companies</a> webpage using python.</p>
  <p>this is the code.</p>
  <pre><code>from selenium import webdriver
  from selenium.webdriver.chrome.service import Service
  import time
  
  
  url = 'https://register.fca.org.uk/s/search?q=capital&amp;type=Companies'
  service = Service('link to chromedriver')
  
  service.start()
  driver = webdriver.Remote(service.service_url)
  
  driver.get(url);
  html = driver.page_source 
  time.sleep(1)
  print(html)
  driver.quit()
  </code></pre>
  <p>I could find the Reference number in html varable.</p>
  <p>could anyone point me to the right direction, how can I get this? there are almost 7000 Reference numbers so write it to the list manually is not a solution.</p>
  <p>Thanks.</p>
  <p>EDIT:
  After fixing the previous issue, I tried to do this kind of thing. navigate to new web page and comes back to the previous web page.</p>
  <pre><code>for d in divs:
  
    RN = ''
    companyName = ''
    companyName =   d.find_element_by_tag_name('h2').text
    RNData = d.find_element_by_xpath('.//div[@class=&quot;result-card_figure-offset&quot;]').text
    RN = RNData.split(':')[1].strip()
  
    d.click()
    time.sleep(12)
  
    phoneNumber = ''
    phoneNumberData =  driver.find_elements_by_xpath('//*[@id=&quot;who-is-this-details-content&quot;]/div[1]/div[2]/div[2]/div/div/div[2]')
    phoneNumber = phoneNumberData[0].text.split('\n')[1]
  
    print(RN)
    print(companyName)
    print(phoneNumber)
  
    driver.execute_script(&quot;history.back();&quot;)
  </code></pre>
  <p>it gives me this Error.</p>
  <pre><code>  selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
  </code></pre>