I'm trying to extract a few simple 'CIK' codes from the 'SEC'. If you run the code below, you will get a pop about a "survey". If you do it manually, you won't see it. It bombs my code. But since it is in selenium, I can't inspect it with chropath to get the xpath to click on the "NO". And I can't recreate the pop up in a normal browser. What do I do?
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from random import randint
path ='C:\\Users\\Jason\\Google Drive\\python\\chromedriver.exe'
ticker='alrm'
main='https://www.sec.gov/search/search.htm'
driver=webdriver.Chrome(path)
tickers=['AAL','AAN','AAOI','AAPL']
# starts the process
def get_CIK(ticker):
driver.get(main)
stock_code = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "cik")))
stock_code.click()
stock_code.send_keys(ticker)
driver.find_element_by_xpath("//input[@value='Find Companies']").click() # click on search buttom
link = driver.find_element_by_xpath("/html[1]/body[1]/div[4]/div[1]/div[3]/span[1]/a[1]").get_attribute("href") # get link
cik= link[link.index('CIK=')+4:link.index("owner")-1] # extract cik
print cik
for i in tickers:
get_CIK(i)