This Python script generates personalized travel itineraries using the Google Places API. It fetches tourist attractions for a specified location, optimizes the route, and allows users to customize their itinerary based on their preferences.
- Fetch tourist attractions for a given location
- Categorize activities into morning, afternoon, and evening slots
- Optimize the route using the Traveling Salesman Problem (TSP) algorithm
- Generate a draft itinerary based on the number of days specified
- Allow user feedback and itinerary adjustment
- Display detailed information about each activity
- Python 3.x
requestslibrarynumpylibrary- Google Places API key
- Clone this repository or download the
places.pyfile. - Install the required libraries:
pip install requests numpy - Obtain a Google Places API key from the Google Cloud Console.
- Replace the
API_KEYvariable in the script with your actual API key.
- Run the script:
python places.py - Follow the prompts to enter:
- The place you want to visit
- Number of days for your trip
- Your interests (comma-separated)
- Review the generated itinerary
- Provide feedback on each activity (rate from 1 to 5)
- Choose to continue providing feedback or finalize the itinerary
fetch_data_for_place(place): Fetches tourist attractions for the given placefetch_distance_matrix(origins, destinations): Retrieves distance matrix for optimizing the routeprioritize_activities(data, interests): Prioritizes activities based on user interestscreate_itinerary(data, days): Generates a draft itinerarytsp_optimization(locations, distance_matrix): Optimizes the route using TSP algorithmreorder_activities(data, optimal_route): Reorders activities based on the optimized routeget_user_feedback(itinerary): Collects user feedback on the itineraryadjust_itinerary(itinerary, feedback, data): Adjusts the itinerary based on user feedbackfetch_place_details(place_id): Retrieves detailed information about a placedisplay_activity_details(activity): Displays detailed information about an activity
This script uses the Google Places API, which may incur costs depending on your usage. Make sure to review the Google Places API pricing before extensive use.
Feel free to fork this repository and submit pull requests with improvements or bug fixes.