This script scrapes the Merriam-Webster dictionary API to fetch definitions and examples for words saved in the user's dictionary.
- Install dependencies:
pip install -r requirements.txt
- Set environment variables:
export MW_EMAIL="your_email"
export MW_PASSWORD="your_password"
export DICT_API_KEY="your_api_key"
python dictionary_scrape.py
--no-stdout
: Disable logging to stdout--no-logfile
: Disable logging to a file
Logs are written to dictionary_scrape.log
by default.
The script outputs a JSON file containing the following structure:
{
"total_words": 123,
"data": [
{
"word": "word1",
"description": "description1",
"examples": ["example1", "example2"]
},
...
]
}
The output is also logged to dictionary_output.json
by default.
- The script uses Selenium to log in and extract cookies from the Merriam-Webster website.
- It then uses the dictionary API to fetch definitions and examples for each word.
- The script is designed to be polite to the server by adding a delay between requests.
MIT License