A simple web scraper that extracts Tesla's revenue data from Macrotrends.
- Extracts revenue data for Tesla from the Macrotrends website.
- Handles 403 Forbidden errors by retrying the request with a custom User-Agent header.
- Python 3
requests
beautifulsoup4
pandas
To set up the project, you will need Python 3. It is recommended to create a virtual environment. You can install the required packages using pip:
-
Import the necessary libraries:
-
Define the URL for Tesla's revenue chart:
-
Retrieve the HTML content of the page:
-
If a 403 Forbidden error is encountered, use a custom User-Agent header to retry the request
Contributions are welcome! If you find a bug or have a feature request, please open an issue. If you'd like to contribute code, please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.