17 Nov 2011

python tip - 截取google docs的pdf地址

收藏到CSDN网摘



截取google docs的pdf地址 import urllib2

s = raw_input('please input url:\n')
while len(s.strip())>0:
if 'cache:' in s:
st = s.find('cache:')+len('cache:')
ss = s[st:]
ss = ss[ss.find(':')+1:]
elif 'url=' in s:
st = s.find('url=')+len('url=')
ss = s[st:]
ed = ss.find('.pdf')+len('.pdf')
ss = ss[:ed]
if 'http' in ss:
print urllib2.unquote(ss)
else:
print 'http://'+ss
s = raw_input('\nplease input url:\n')

No comments :

Post a Comment