Daima 0 Newbie Poster

hello everyone (:

I am learing python about now for 1 months and i am busy to make a autologing script with a post function. But i am stuck ): the login part is working but i cant get the post function to work.. Can someone look to my script?

import urllib, urllib2, cookielib, time

cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders.append(('User-agent', 'Mozilla/4.0'))
opener.addheaders.append( ('Referer', 'http://127.0.0.1/login.html') )
           
login_data = urllib.urlencode({'user' : 'test_user', 'pass' : 'test3214', 'Loginkp' : 'class="knop"'})

#login start
resp = opener.open('http://127.0.0.1/login.html', login_data)
resp.close()
#start pagina
resp = opener.open('http://127.0.0.1/user/')

d = resp.read()
if d.find("test_user") != -1:
	print "ingelogt %s" %d.find("test_user")
resp.close()

opener.addheaders.extend( ('Referer', 'http://127.0.0.1/login.html') )
opener.addheaders.append( ('Referer', 'http://127.0.0.1/place.htm') )
place_data2 = urllib.urlencode({'idd' : '5', 'gp' : '2', 'todo' : 'NEW', 'titel' : 'new_user', 'text' : 'Hello this is a test', 'year' : '2010', 'adm' : '', 'adm2' : '1', 'placeknp' : 'class="knop"'  })
resp = opener.open('http://127.0.0.1/place.html', place_data2)
resp.close()

If i run this code i get the next error: ValueError: too many values to unpack
how can i solve this problem.. :D

Thanks you very much :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.