google-maps-scraper
google-maps-scraper copied to clipboard
Add Shell Arguments
I propose that the application takes parameters via command line instead of hardcoding them in main.py. Also the output should be written to stdout (easily redirected to a file if needed).
I have changed a script a little bit for my use case. This is incomplete and just a quick glimplse for how I think it should look like.
from src.gmaps import Gmaps
import argparse
import sys
parser = argparse.ArgumentParser()
parser.add_argument("query", type=str)
parser.add_argument("-m", "--max-results", type=int, default=None)
parser.add_argument("--has-website", action="store_true", default=None)
parser.add_argument("--has-phone", action="store_true", default=None)
parser.add_argument("--fields", type=str, nargs="+", default="default")
args = parser.parse_args()
sys.stderr.write(str(args) + "\n")
Gmaps.places([args.query],
max=args.max_results,
has_website=args.has_website,
has_phone=args.has_phone,
fields=args.fields)
Use it like
python main.py --has-website --has-phone --fields name website phone owner address --max-results 100 "restaurants in paris" > "restaurants.json"
Benefits:
- It can be easily used as part of other scripts
- The results can be piped to other scripts
- No need to edit files for each run
We are working creating an API version which you may use with curl instead of shell arguments.
Release new version with API Integration, Kindly run command
python -m pip install bota botasaurus_api botasaurus_driver bota botasaurus-proxy-authentication botasaurus_server --upgrade
and then run the below commands 1️⃣ Clone the Magic 🧙♀️:
git clone https://github.com/omkarcloud/google-maps-scraper
cd google-maps-scraper
2️⃣ Install Dependencies 📦:
python -m pip install -r requirements.txt && python run.py install
3️⃣ Launch the UI Dashboard 🚀:
python run.py