Getting Google Maps Address with Python

0Shares
Reading Time: 3 minutes

Getting Google Maps Address with Python

Here is another small script using the webbrowser module and the sys module. It will take an inputted address and search it directly on google maps.

The webbrowser module comes with python and it’s used to open your default web browser to a specified page.

The sys provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter.

All one would need to do is to run the script is open it in cmd or terminal and write in the address after the file name.




The Code

Download this python script on github.

How It works

First we import webbrowser and sys.

Next we used an if statement to check that there is an address written after file name and we store that input into the address variable.

The sys.argv variable will contain the list value of [‘GoogleMap.py’, ‘123’, ‘main’, ‘st’, ‘etc…’], so we used [1:] to chop off the first element of that list since it’s not part of the address.

Lastly we use webbrowser.open() to open the google maps url and added our address to the end of it.

Just like that we have a google maps page open with our address already inserted. Feel free to try opening up a browser to a weather website and getting the temperature for your location.

Thanks for reading. Feel free to leave a comment below with any questions or ideas we can build off from.

 

Turn into a Python Pro!

Come on over and take a look at “Automate the Boring Stuff with Python: Practical Programming for Total Beginners“. If you’ve ever spent hours renaming files or updating hundreds of spreadsheet cells, you know how tedious tasks like these can be. But what if you could have your computer do them for you?

In Automate the Boring Stuff with Python, you’ll learn how to use Python to write programs that do in minutes what would take you hours to do by hand—no prior programming experience required. Once you’ve mastered the basics of programming, you’ll create Python programs that effortlessly perform useful and impressive feats of automation to:
–Search for text in a file or across multiple files
–Create, update, move, and rename files and folders
–Search the Web and download online content
–Update and format data in Excel spreadsheets of any size
–Split, merge, watermark, and encrypt PDFs
–Send reminder emails and text notifications
–Fill out online forms

This post “Getting Google Maps Address with Python” is located under the Programming Category

Learn how to create a Simple Email Scraper Written in Python!

 

0Shares

admin

Leave a Reply

Your email address will not be published.