This Python script utilizes the Selenium library to scrape data from Amazon's laptop search results. The script extracts the product title, price, and link for each laptop listed on the page and saves this information to a file in the "my_files" directory. Finally, the script reads the saved files and extracts the same information into a list of dictionaries.
- Python 3
- Selenium library
- ChromeDriver executable for Selenium
- Create a Virtual Environment
python -m venv venv
- Activate The Virtual Environment
venv/Scripts/activate
source venv/bin/activate
- Install Requirements
pip install -r requirements.txt
- Download WebDriver
- Go to This Page and Download Version Based On Your Chrome Version.
- Put the
chromedriver.exe
file inC-D
folder.
-
Open a command prompt or terminal window.
-
Navigate to the directory where the script is saved.
-
Run the script using the command
python main.py
. -
The script will launch a headless Chrome browser and navigate to the search results page for Asus laptops on Amazon.
-
The script will then extract the product title, price, and link for each laptop listed on the page, and save this information to a file in the "my_files" directory.
-
Finally, the script will read the saved files and extract the same information into a list of dictionaries.
-
The resulting list of dictionaries can be used for further processing, such as storing the data in a database or generating a report.
This Amazon web scraper script can be useful for extracting data from various pages on the Amazon website or other e-commerce sites. It demonstrates how the Selenium library can be used to automate web browsing and extract data from web pages.