Prev: Comments on PyPI
Next: universal newlines and utf-16
From: BJ Swope on 11 Apr 2010 09:40 I am trying to automate access to a web page that has forms based authentication. The password field is named "pass" which python is not going to like. Other than asking the website owner to change the name of the field how can I go about passing that field in the form post? dev:~$ python Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import urllib >>> params = urllib.urlencode(dict(past='foo')) >>> params = urllib.urlencode(dict(passs='foo')) >>> params = urllib.urlencode(dict(pass='foo')) File "<stdin>", line 1 params = urllib.urlencode(dict(pass='foo')) ^ SyntaxError: invalid syntax
From: Giampaolo Rodola' on 11 Apr 2010 09:45 On 11 Apr, 15:40, BJ Swope <bigbluesw...(a)gmail.com> wrote: > I am trying to automate access to a web page that has forms based > authentication. The password field is named "pass" which python is > not going to like. > > Other than asking the website owner to change the name of the field > how can I go about passing that field in the form post? > > dev:~$ python > Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) > [GCC 4.3.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> import urllib > >>> params = urllib.urlencode(dict(past='foo')) > >>> params = urllib.urlencode(dict(passs='foo')) > >>> params = urllib.urlencode(dict(pass='foo')) > > File "<stdin>", line 1 > params = urllib.urlencode(dict(pass='foo')) > ^ > SyntaxError: invalid syntax >>> urllib.urlencode({'pass' : 'foo'}) 'pass=foo' >>> --- Giampaolo http://code.google.com/p/pyftpdlib http://code.google.com/p/psutil
From: Duncan Booth on 11 Apr 2010 09:47 BJ Swope <bigblueswope(a)gmail.com> wrote: > Other than asking the website owner to change the name of the field > how can I go about passing that field in the form post? > > dev:~$ python > Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) > [GCC 4.3.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import urllib >>>> params = urllib.urlencode(dict(past='foo')) >>>> params = urllib.urlencode(dict(passs='foo')) >>>> params = urllib.urlencode(dict(pass='foo')) > File "<stdin>", line 1 > params = urllib.urlencode(dict(pass='foo')) > ^ > SyntaxError: invalid syntax > > Create your dictionary without using keyword arguments: fields = {'pass':'foo'} params = urllib.urlencode(fields)
From: BJ Swope on 11 Apr 2010 09:57 >>>> urllib.urlencode({'pass' : 'foo'}) > 'pass=foo' >>>> > > > --- Giampaolo > http://code.google.com/p/pyftpdlib > http://code.google.com/p/psutil > -- > http://mail.python.org/mailman/listinfo/python-list > Thank you!
|
Pages: 1 Prev: Comments on PyPI Next: universal newlines and utf-16 |