[Tutor] python + sharepoint
Steven D'Aprano
steve at pearwood.info
Sat Mar 3 03:35:10 CET 2012
Brad Hudson wrote:
> Still no response on this one, but I did find a 'rather ugly' solution
> using subprocess for wget to get a file from sharepoint...
>
> #!/usr/bin/env python
>
> import getpass
> import re
> import shlex
> from subprocess import Popen, PIPE
>
> # build sharepoint user/pw
> # note: shlex.split requires both a raw and escaped domain string
> user = r'DOMAIN\\ID'
> pw = getpass.getpass('password: ')
> url = 'http://myserver.com/myfile.txt'
> cmd = 'wget --no-proxy --user=%s --password=%s -O- %s' % (user, pw, url)
Ah.
Well that explains why your version using urllib2 failed -- you don't give a
username or password, and sharepoint (whatever that is!) requires one.
You might have said.
You can read the Fine Manual, which describes how to fetch Internet resources:
http://docs.python.org/howto/urllib2.html
That is written for Python 2.7, here's one for 2.4:
http://docs.python.org/dev/howto/urllib2.html
Since you need to authenticate, this will probably be helpful:
http://www.voidspace.org.uk/python/articles/authentication.shtml
--
Steven
More information about the Tutor
mailing list