0BxmEiwnrWfmmTjlIVmE0S01YM0U:
from mechanize import Browser
import re
br = Browser()
br.set_handle_robots( False )
br.addheaders = [('User-agent', 'Firefox')]
id = "0BxmEiwnrWfmmTjlIVmE0S01YM0U"
r = br.open('http://docs.google.com/uc?id='+id+'&export=download')
regex = 'download&confirm=(.+?)&id'
pattern = re.compile(regex)
html = r.read()
confirm = re.findall(pattern,html)
print confirm
download&confirm= and &id is just the identificator for start and end text 1:1 from html source.There are no special characters.
(.+?) just says "Take the content between!"

Next one will print also filename
from mechanize import Browser
import re
br = Browser()
br.set_handle_robots( False )
br.addheaders = [('User-agent', 'Firefox')]
id = "0BxmEiwnrWfmmTjlIVmE0S01YM0U"
r = br.open('http://docs.google.com/uc?id='+id+'&export=download')
html = r.read()
confirm = re.findall('download&confirm=(.+?)&id',html)
filename = re.findall(id+'">(.+?)</a> \(',html)
print confirm
print filename
there are reg expression special character \(in id+'">(.+?)</a> \(
Install Python2 with mechanize and BeautifulSoup module for windows
No comments:
Post a Comment