how to re-create Python's Mechanize package

How would I go about structuring code to perform the following task:

I want to send a URL and acquire the html contents, including simulating a user clicking a Form Submit button -
Basically I am wondering how to re-create Python’s Mechanize package.


You can either grab the HTML via a HTTPSocket and then do a post back to the server
You can use a HTMLViewer, load the webpage and then use JavaScript to “click” the button…