Created
January 24, 2021 13:35
-
-
Save kotoripiyopiyo/870d68ee30b0fd29f9fe55af44beda13 to your computer and use it in GitHub Desktop.
地図検索
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# mapIt.py コマンドラインやクリップボードに指定した住所の地図を開く | |
import webbrowser, sys, pyperclip, urllib.parse | |
if len(sys.argv) > 1: | |
# コマンドラインから住所を取得する | |
address = ' '.join(sys.argv[1:]) | |
else: | |
# クリップボードから住所を取得する | |
address = pyperclip.paste() | |
# 住所をURLエンコーディングする | |
address = urllib.parse.quote(address) | |
# ブラウザにURLを渡す | |
webbrowser.open('https://www.google.com/maps/place/' + address) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
工夫ポイント:住所をURLエンコードする。
『退屈なことはPythonにやらせよう』11章Webスクレイピングより