Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8573459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:15:18+00:00 2026-06-11T19:15:18+00:00

I am trying to do some automation in a Python script and I have

  • 0

I am trying to do some automation in a Python script and I have run into a problem. I am trying to do a POST to a server.

url = 'http://www.example.com'
params = {'arg0': 'value', 'arg1': '+value'}

f = urllib.urlopen(url, urllib.urlencode(params))
print f.read()

I have done a wireshark capture of the equivalent browser operation, where the second arg, arg1 is passed as +value, however when I do it with Python the + gets changed to %2B, i.e.

Line-based text data: application/x-www-form-urlencoded
arg0=value&arg1=%2Bvalue

when it should be:

Line-based text data: application/x-www-form-urlencoded
arg0=value&arg1=+value

I have also used the Requests module and it seems to do the same thing.

url = 'http://www.example.com'
params = {'arg0': 'value', 'arg1': '+value'}

f = requests.post(url, params)

Google is not your friend when you have a problem related to ‘+’ as it seems to be a catch all for so much else.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:15:20+00:00Added an answer on June 11, 2026 at 7:15 pm

    The + character is the proper encoding for a space when quoting GET or POST data. Thus, a literal + character needs to be escaped as well, lest it be decoded to a space on the other end. See RFC 2396, section 2.2, section 3.4 and the HTML specification, application/x-www-form-urlencoded section:

    Control names and values are escaped. Space characters are replaced by `+’, and then reserved characters are escaped as described in [RFC1738], section 2.2.

    If you are posting data to an application that does not decode a + character to a space but instead treats such data as literal plus signs instead, you need to encode your parameters yourself using the urllib.quote function instead, specifying that the + character is not to be encoded:

    import urllib
    def urlencode_withoutplus(query):
        if hasattr(query, 'items'):
            query = query.items()
        l = []
        for k, v in query:
            k = urllib.quote(str(k), safe=' /+')
            v = urllib.quote(str(v), safe=' /+')
            l.append(k + '=' + v)
        return '&'.join(l)
    

    Demo:

    >>> urlencode_withoutplus({'arg0': 'value', 'arg1': '+value'})
    'arg0=value&arg1=+value'
    

    When using requests, you can simply pass in the result of the above function as the data value, but in that case you need to manually set the content type:

    requests.post(url, urlencode_withoutplus(query),
        headers={'Content-Type': 'application/x-www-form-urlencoded'})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use python to help do some automation around an incremental
I am relatively new to Python. I am trying to do some web automation
I'm trying to do some browser automation, but I'm having some problems. Basically, what
I am trying to use some Word 2007 automation where we give the user
I am trying to increase the speed of some UI Automation operations. I stumbled
Recently I was trying some practice programs in python and I came across this
I'm trying to create a database connection in a python script to my DB2
I'm trying to use some IE automation to process various internal webpages. Some of
I'm trying to find some useful Open Source Testing Automation Tools for use with
I am trying to create an automation to perform some action to a HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.