For a self-proclaimed newbie to Python, you've gone about trying to solve the problem in a very intelligent and sensible way. For the most part, you appear to do everything perfectly correct.
The only thing I can spot that might be wrong with it is the URL you send the POST data to. I took a look at the source for the
Sandbox edit page, and noticed this line:
<form id="editform" name="editform" method="post" action="/w/index.php?title=
Wikipedia:Sandbox&action=submit" enctype="multipart/form-data">
The edit form appears to submit with "action=submit", whilst the URL you pass to urllib has "action=edit". At a guess, I'd say that the 'edit' action displays the edit page, whilst the 'submit' action is designed to handle data submitted from forms.
Try changing your urllib call to:
f = urllib.urlopen("http://en.wikipedia.org/w/index.php?title=Wikipedia:Sand
box&action=submit", params) And see if that makes any difference. Also, the default edit page for the sandbox contains the line:
{{Please leave this line alone (sandbox heading)}} So it might be an idea to prepend this line to your wpTextbox1 value:
urllib.urlencode({
'wpTextbox1': "{{Please leave this line alone (sandbox heading)}}\ntest1",
'wpCommment': 'This is the first test', 'wpSave':1}) Just so that you don't mess anything up for Wikipedia
