Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question wrt to scraping a list of all symbols #1899

Open
synergiator opened this issue Apr 8, 2024 · 1 comment
Open

Question wrt to scraping a list of all symbols #1899

synergiator opened this issue Apr 8, 2024 · 1 comment

Comments

@synergiator
Copy link

synergiator commented Apr 8, 2024

Is there a way to scrape all symbols? I was not able to identify this feature in yfinance after some research; in case it's available, kindly advise - otherwise I hope this can be a valid feature request.

Desired output should be a sorted dictionary, similar to: {"AAPL", "ACME", ..... "ZZZ"}

What I could find so far, there is a standalone script which however as of today can't overcome the cookie accept form on the site. Side question - how does yfinance manage this?

Workaround: use Selenium in Docker to accept the cookies form and scrape the page.

Something like the following:

driver = webdriver.Chrome()
driver.get(url)
accept_button = WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((By.XPATH, '//button[text()="Accept all"]'))
    )
accept_button.click()
element = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.ID, 'lookup-page'))
)

html_content = driver.page_source

@ValueRaider
Copy link
Collaborator

yf already uses cookies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants