This script scrapes Reddit for activities and things to do in Mexico City using the PRAW (Python Reddit API Wrapper) library.
- Install the required dependencies:
pip install -r requirements.txt-
Create a Reddit application:
- Go to https://www.reddit.com/prefs/apps
- Click "create another app..."
- Choose "script"
- Fill in the required information
- Note down your client ID and client secret
-
Create a
.envfile in the project root with the following variables:
REDDIT_CLIENT_ID=your_client_id
REDDIT_CLIENT_SECRET=your_client_secret
REDDIT_USER_AGENT=your_user_agent
Run the script:
python mexico_city_activities.pyThe script will:
- Search through multiple Mexico City-related subreddits
- Look for posts about activities and things to do
- Save the results to
mexico_city_activities.json
The script generates a JSON file containing:
- Post titles
- URLs
- Scores (upvotes)
- Creation dates
- Subreddit sources
- Post content (first 500 characters)
- Number of comments
The results are sorted by score and duplicates are removed.
To see it work locally, run
python app.py