Download app.py from BluechipTechnologiesAsia/Google-Maps.Location-data-scraper: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/spaces/BluechipTechnologiesAsia/Google-Maps.Location-data-scraper/resolve/main/app.py
- Command line
-
hf download hf://spaces/BluechipTechnologiesAsia/Google-Maps.Location-data-scraper/app.py
-
curl -L -o app.py https://huggingface.co/spaces/BluechipTechnologiesAsia/Google-Maps.Location-data-scraper/resolve/main/app.py
1.41 kB
| from flask import Flask, render_template, request | |
| from parser_1 import gmaps_parser | |
| app = Flask(__name__) | |
| def display_data(): | |
| location = None | |
| country_code = None | |
| error_message = None | |
| all_place_details = [] | |
| if request.method == "POST": | |
| location = request.form.get("location") | |
| country_code = request.form.get("country_code") | |
| if location and country_code: | |
| scraped_data = gmaps_parser(location=location, country_code=country_code) | |
| try: | |
| list = scraped_data["scrapingResult"]["locals"] | |
| except KeyError: | |
| error_message = "Error: Data might be unavailable for this location." | |
| else: | |
| error_message = "" | |
| for place in list: | |
| try: | |
| place_details = [place['title'], place['address'], place['website']] | |
| except KeyError: | |
| error_message = "Error: Data might be unavailable for this location." | |
| else: | |
| all_place_details.append(place_details) | |
| all_place_details=all_place_details | |
| return render_template("data.html", location=location, country_code=country_code, all_place_details=all_place_details, error_message=error_message) | |
| if __name__ == "__main__": | |
| app.run(debug=True) | |