
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python script to open a Google Map location on clipboard?
We generally open the browser to search for a specific site/place on google maps. And if you need to do this task multiple times a day, it becomes very boring. Now you can automate this task where your browser will open automatically and the webpage will show you the google maps of your desired location.
Installation
For this purpose, I’m going to use the paperclip package. As this is not the standard package, we need to install it using pip.
>pip install pyperclip Collecting pyperclip Downloading https://files.pythonhosted.org/packages/2d/0f/4eda562dffd085945d57c2d9a5da745cfb5228c02bc90f2c74bbac746243/pyperclip-1.7.0.tar.gz Building wheels for collected packages: pyperclip Building wheel for pyperclip (setup.py) ... done Stored in directory: C:\Users\rajesh\AppData\Local\pip\Cache\wheels\92\f0\ac\2ba2972034e98971c3654ece337ac61e546bdeb34ca960dc8c Successfully built pyperclip Installing collected packages: pyperclip Successfully installed pyperclip-1.7.0
Steps to accomplish this:
First read the desired address either from the command line argument or from the clipboard.
Second using the webbrowser module to automatically open default web browser with the desired address.
Require sys module to access the command line stored in argv list.
Lastly use pyperclip module to access from the clipboard.
Example Code
#webbrowser module helps in open default web browser of os from webbrowser import open #sys contains command line arguments from sys import argv #To access clipbord from pyperclip import paste if len(argv)>1: address = " ".join(argv[1:]) else: address = paste() open("http://www.google.com/maps/place/"+address)
Output
- Related Articles
- How to show current location on a google map on Android?
- How to show current location on a Google Map on Android using Kotlin?
- Get a google map image of specified location using Google Static Maps API in Python
- How to best display HTML5 geolocation accuracy on a Google Map?
- Plotting Data on Google Map using pygmaps package?
- Plotting Google Map using gmplot package in Python?
- How to open a file in the same directory as a Python script?
- How to detect touch and its position on Google map in Android?
- Why Google embedded Map Makers inside Google Maps?
- Autorun a Python script on windows startup?
- Plotting Google Map using folium package?
- How to run Python code on Google Colaboratory?
- Creating ‘Copy to Clipboard’ feature on a web page with JavaScript
- How to execute Python CGI Script on Apache Server?
- Difference between Google Script (.GS) and JavaScript (.js)
