![]() ![]() Print('Ticker symbol CLI argument missing!') Let’s modify the script to make read the ticker from a command line argument. For example, “AMZN” is the ticker symbol of the Amazon stock. If you are not familiar with the concept, that is a string abbreviation used to uniquely identify shares traded in the stock market. This is what the URL of a Yahoo Finance stock page looks like: Īs you can see, it is a dynamic URL that changes based on the ticker symbol. You will use that soon to implement the data extraction logic. This script simply instantiates an instance of Chrome WebDriver. # close the browser and free up the resources # initialize a web driver instance to control a Chrome windowĭriver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install())) Thanks to it, you do not have to manually download, configure, and import the web driver.įrom import Service as ChromeServiceįrom webdriver_manager.chrome import ChromeDriverManager However, it is highly recommended as it makes managing web drivers in Selenium way easier. Webdriver-manager is not strictly required. Install Selenium and the Webdriver Manager with the following terminal command: pip install selenium webdriver-manager It only remains to add the project’s dependencies. Great, you now have a Python project for your finance scraper. ![]() In the terminal, you should see: Hello, World! Launch it to verify that it works with: python scraper.py Right now, it is a sample script that only prints “Hello, World!” ![]() You will add the logic to scrape Yahoo Finance here. Inside it, add a scraper.py file as below: print('Hello, World!') These will initialize the yahoo-finance-scraper project folder. Next, use the commands below to set up a Python project with a virtual environment:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |