8

Sort of like a bot, i have already checked out some sites such as pyjamas and scrapy, I know how to print data of websites, but still dont know how to interact with buttons. Can somebody help me with some demonstarative code?

Lets say i have a form

<form name="input" action="html_form_action.asp" method="get">
Username: <input type="text" name="user" />
<input type="submit" value="Submit" />
</form>

how do i identify the button to be clicked, so that python can click it for me? If anybody knows any sites with demonstarative code, i would be very pleased.

2
  • huh? what has this to do with Python? If you want to submit data to some webserver then you have to perform a proper HTTP GET/POST request - this is something completely different then reading HTML and parsing it. Perhaps you should understand first what happens on the client and what on the server - basic HTTP know-how should be expectable if you deal with HTML. Tools like mechanize are way to deal with that. Commented Apr 17, 2011 at 11:34
  • a HTTP GET/POST request was probably a bad example, if anybody knows KoL mafia, something like this is what i am trying to make. Commented Apr 17, 2011 at 11:39

2 Answers 2

10

You can use mechanize for that. It provides an easy way for interacting with websites.

Sign up to request clarification or add additional context in comments.

Comments

5

If you’re looking to really simulate a browser, you might want to look at Selenium, which allows you to control a real web browser.

If the website you’re looking to interface with uses a lot of JavaScript (e.g. onclick handlers), it can be very handy.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.