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

  • Home
  • SEARCH
  • 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 5849779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:02:56+00:00 2026-05-22T13:02:56+00:00

I have to fill in multiple form fields on a web page I got

  • 0

I have to fill in multiple form fields on a web page
I got the http POST part completed so I can post data to the web page.
I also got the part completed where I create a dictionary of key/value pairs and have the form fields filled on the web page.

Key/value pairs:

input1 = {'hostname' : 'host', 'port' : '22', 'basedn' : 'CN=Users', 'bindusername' : 'admin', 'bindpassword' : 'passwd', 'groupname' : 'CN=Group,CN=Users,DC=tech,DC=com', 'usernameattribute' : 'name'}

for line in open("/Users/rwettstein/Scripts/Files/ldap-settings.txt", "r"):
    print line
    input = line
    time.sleep(10)

    params = urllib.urlencode(dict(input))

try:
    f_handler = urlopen('https://hostname/path/file.php', params)
    except urllib2.HTTPError, error:
        print "Error Code: %s" % error.code

However, if I place the key/value pair information into a text file and then read the data from the text file, read from the file line by line, encode it into a dictionary, and then hand it off to the Http Request, I get the following error:

ValueError: dictionary update sequence element #0 has length 1; 2 is required

Is this error occurring because the value being passed from the file read function only returns one single argument?

  • 1 1 Answer
  • 1 View
  • 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-05-22T13:02:57+00:00Added an answer on May 22, 2026 at 1:02 pm

    Use ast.literal_eval to parse each line into a dict. I’ve modified your code a little to show how it’s done.

    import ast
    
    input1 = {'hostname' : 'host', 'port' : '22', 'basedn' : 'CN=Users', 'bindusername' : 'admin', 'bindpassword' : 'passwd', 'groupname' : 'CN=Group,CN=Users,DC=tech,DC=com', 'usernameattribute' : 'name'}
    
    for line in open("/Users/rwettstein/Scripts/Files/ldap-settings.txt", "r"):
        print line
        # this assumes each line has a dictionary literal in it.
        # you can add more robust processing (e.g. skipping empty lines
        # or lines starting with #)
        input = ast.literal_eval(line.strip())
        time.sleep(10)
    
        # this assumes input is a dict or a sequence of key/value tuples.
        params = urllib.urlencode(input)
    
    try:
        f_handler = urlopen('https://hostname/path/file.php', params)
        except urllib2.HTTPError, error:
            print "Error Code: %s" % error.code
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form where a user can add multiple select boxes for multiple
I have created following function to fill field of a form page, there is
I have two fields that need to multiply each other and fill a third
I have a form which users must fill out and submit. The controller action
I have a from where you can fill in any combination of your home,
I got many panels and one form. I have employed panels so I don't
I have some code that does custom drawing. Basically it is form fill program
I have a form that users fill out, and on the form there are
I have a form which the user has to fill in. A couple of
I have multiple literals on a page. For example, <asp:Literal id=Label1 runat=server /> I

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.