This Python script uses the Gaode (Amap) API to find nearby restaurants and randomly selects one for your next meal. The script can be scheduled using crontab
to remind you where to eat lunch or dinner.
- Retrieves nearby restaurants based on your current location.
- Sorts restaurants by rating.
- Randomly selects a restaurant from the list.
- Can be scheduled to run automatically using
crontab
.
- Python 3.x
requests
library
git clone https://github.com/yourusername/restaurant_picker.git
cd restaurant_picker
Navigate to your project directory and create a virtual environment:
python3 -m venv venv
On macOS/Linux:
source venv/bin/activate
On Windows:
.\venv\Scripts\activate
Install the required dependencies:
pip install requests
Alternatively, you can install dependencies from a requirements.txt
file (if available):
pip install -r requirements.txt
Sign up for a Gaode developer account and create a new project to obtain an API key. You can sign up here.
You need to set two environment variables:
GAODE_API_KEY
: Your Gaode API key.MY_LOCATION
: Your current location inlongitude,latitude
format.
Example:
export GAODE_API_KEY=your_api_key
export MY_LOCATION=116.397128,39.916527 # Example for Beijing
To run this script automatically for lunch and dinner reminders, you can set up a cron job.
Edit your crontab
:
crontab -e
Add the following lines to run the script at 12 PM and 6 PM every day:
0 12 * * * /bin/bash -c "source /path_to_project/venv/bin/activate && python /path_to_project/restaurant_picker.py >> ~/restaurant_picker.log 2>&1"
0 18 * * * /bin/bash -c "source /path_to_project/venv/bin/activate && python /path_to_project/restaurant_picker.py >> ~/restaurant_picker.log 2>&1"
Replace /path_to_project/
with the full path to your project directory.
Run the script manually to test if it works correctly:
python restaurant_picker.py
The script will fetch nearby restaurants and randomly suggest one based on ratings.
This project is open-source and available under the MIT License.
Feel free to update the repository link, license, or any other project-specific information.