Created
March 16, 2012 12:02
-
-
Save codeinthehole/2049780 to your computer and use it in GitHub Desktop.
Desired API for a python URL object
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
import requests | |
from someurllib import URL | |
# 1. Build request URL | |
url = URL(host='maps.google.com') | |
url.path('/geocoding/xml/') | |
.param('q', 'Some address string') | |
.param('sensor', 'False') | |
.fragment('something') | |
response = requests.get(str(url)) | |
# 2. Extract info from URL | |
url = URL.from_string('https://google.com/some/path/here/?q=testing') | |
print url.path_segment(2) # 'here' | |
print url.param('q') # 'testing' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment