Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

unshorten url python

# This is for Py2k.  For Py3k, use http.client and urllib.parse instead, and
# use // instead of / for the division
import httplib
import urlparse

def unshorten_url(url):
    parsed = urlparse.urlparse(url)
    h = httplib.HTTPConnection(parsed.netloc)
    h.request('HEAD', parsed.path)
    response = h.getresponse()
    if response.status/100 == 3 and response.getheader('Location'):
        return response.getheader('Location')
    else:
        return url
Comment

PREVIOUS NEXT
Code Example
Python :: how to clear the screen of the terminal using python os 
Python :: python printing to a file 
Python :: .encode python 
Python :: django static files / templates 
Python :: datetime to int in pandas 
Python :: exclude index column pandas 
Python :: python set and dictionary comprehensions 
Python :: seaborn countplot 
Python :: pandas count the number of unique values in a column 
Python :: sort dict by values 
Python :: curl python 
Python :: keras.layers.simplernn 
Python :: neuronal network exemple python 
Python :: python pandas apply function to one column 
Python :: input command in python shell 
Python :: how to close opencv window in python 
Python :: standard scaler vs min max scaler 
Python :: isnumeric 
Python :: python open and read file with 
Python :: python how to add turtle in tkinter 
Python :: turn df to dict 
Python :: set header in dataframe 2nd line 
Python :: if else python 
Python :: python allowed variable caracters 
Python :: kafka get last offset of topic python 
Python :: how to insert a variable into a string python 
Python :: python generate random string 
Python :: fnd closest element in array numpy 
Python :: python ftplib get list of directories 
Python :: Get all the numerical column from the dataframe using python 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =