Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Convert dictionary to HTTP POST

Reply
Thread Tools

Re: Convert dictionary to HTTP POST

 
 
Laszlo Zsolt Nagy
Guest
Posts: n/a
 
      03-03-2006
>
>
>See urllib.urlencode(). No idea why they don't include it in urllib2 as
>well, but there you go.
>
> >>> from urllib import urlencode
> >>> urlencode({'a':'& "Simple string"', 'b': '<>!@#$%^&*()_+='})

>'a=%26+%22Simple+string%22&b=%3C%3E%21%40%23%24%2 5%5E%26%2A%28%29_%2B%3D'
> >>>

>
>

Hmm. urlencode is using quote_plus internally. Looks like there is no
difference in the encoding of the apostrophe.
I tried to create a very basic form and realized that the problem is NOT
with the quoting.
I'm writting a program that puts orders into a wholesaler's database.
They do not have a programatic interface, so I have to login and post
forms using a program.
There are some fields that I must not change, so I have to read the
value from the HTML source and then post it back.
Here is the problem:

<html>
<body>
<form method="POST">
<input name="name" value="Bessy's cat">
<input type="submit">
</form>
</body>
</html>

The values of some inputs are encoded using html entities.
How can I decode a string like "Bessy's cat" in "Bessy's cat"?

Thanks,

Laszlo

 
Reply With Quote
 
 
 
 
Sybren Stuvel
Guest
Posts: n/a
 
      03-03-2006
Laszlo Zsolt Nagy enlightened us with:
> The values of some inputs are encoded using html entities. How can
> I decode a string like "Bessy's cat" in "Bessy's cat"?


This should help:
http://docs.python.org/lib/module-htmlentitydefs.html

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa
 
Reply With Quote
 
 
 
 
Kent Johnson
Guest
Posts: n/a
 
      03-03-2006
Laszlo Zsolt Nagy wrote:
> The values of some inputs are encoded using html entities.
> How can I decode a string like "Bessy's cat" in "Bessy's cat"?


http://groups.google.com/group/comp....e6c2f6c3d46e9c

Kent
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP SOAP/HTTP GET/HTTP POST milan_9211 Software 0 01-10-2011 02:10 PM
creating a dictionary from a dictionary with regex james_027 Python 1 08-22-2007 07:39 AM
Re: Convert dictionary to HTTP POST Laszlo Zsolt Nagy Python 0 03-03-2006 02:19 PM
Convert dictionary to HTTP POST Laszlo Zsolt Nagy Python 1 03-03-2006 09:22 AM
[DICTIONARY] - Copy dictionary entries to attributes Ilias Lazaridis Python 6 02-21-2006 11:27 AM



Advertisments