0

I have just started to look into Python.

Site: http://toolserver.org/~diberri/cgi-bin/html2wiki/index.cgi

Is it possible for a bot to put data in the top box, maybe tick a box or something, and click the button at the bottom "convert"?

Oh and also, under the Options header, there is a box where you can choose various options. How exactly do you get the bot to choose one of them?

Thanks

Andreas Louv
  • 46,145
  • 13
  • 104
  • 123
user1915496
  • 65
  • 1
  • 8
  • 1
    Have you done any serious research first before asking? –  Dec 22 '12 at 11:16
  • When I first created this question, for some reason it was linking me to IRC bots. So that's not what I had in mind I have searched google, but I wasn't sure what exactly to search for. "How to make a bot input data onto a website"?, "Make a bot access a web page"?. But yes, I have looked. Is there any module I could use/documentation I can read? – user1915496 Dec 22 '12 at 11:19
  • See http://stackoverflow.com/questions/7047790/how-can-i-input-data-into-a-webpage-to-scrape-the-resulting-output-using-python, maybe – irrelephant Dec 22 '12 at 11:23

1 Answers1

1

Of course you can but you will not input HTML code with your bot. If you look at the source code for the page you will see:

<form method="post" action="index.cgi">
<fieldset style="display:none">
  <input type="hidden" name="m" value="convert" />
</fieldset> 
...

It does say that the form uses the method post to this uri: http://toolserver.org/~diberri/cgi-bin/html2wiki/index.cgi

So now you can look at urllib2, urllib2 which is the python lib for http requests. And create your post request with the parameter you want.

E.g:

params = {
  'dialect' : googlecode,
  'uri' : myuri
}

You will need a header, telling the server who is doing the request:

E.g:

headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

Something like this:

u = urllib2.urlopen(' http://toolserver.org/~diberri/cgi-bin/html2wiki/index.cgi', params)
h.request('POST', ' http://toolserver.org/~diberri/cgi-bin/html2wiki/index.cgi', params, headers)
Kirell
  • 9,228
  • 4
  • 46
  • 61