WestMichiganRubyTraining / discussion

Create issues on this repository to open discussion threads in the Issue Tracker!
2 stars 0 forks source link

Is it possible to create a bot in Ruby that interacts with pages like a normal user? #32

Open atkolkma opened 11 years ago

atkolkma commented 11 years ago

I am looking at creating some valuable automation at work. It would involve updating pages through a back end tool used by auto dealers to keep their inventory updated. There is no API for this. A user has to log in, click on some links, put text into certain fields and then submit. I would like to automate this completely, but I'm not sure if it can be done or how you would implement this. Would I just be sending HTTP Post and Get requests via Ruby?

I would also need to have Ruby read through rendered HTML that was served up on certain pages. I'm sure this is possible, but I don't have any experience with this. Can anyone paint, in broad strokes, what is involved in this? Just trying to get a general bearing on how to approach the project.

toreyheinz commented 11 years ago

Yep,

Check out: https://github.com/sparklemotion/mechanize http://railscasts.com/episodes/191-mechanize

If you need more help, let me know.

Torey

atkolkma commented 11 years ago

Thanks, Torey! This is a good place to start.

coderbydesign commented 11 years ago

I second Torey's suggestions. Mechanize should give you exactly what you need to get started!

ThomasBush commented 11 years ago

I have done this as well. We talked at the end of the last ruby meeting. Like Torey and Keith mentioned, you will want to use mechanize to accomplish this. You will write these into rake tasks which you can run from the command line. Also watch that railscasts episode. If you have specific needs I may be able to help. Imagery was a bit tricky at first, at least for me, depending on what you need to accomplish. Once you figure it out however it can be very powerful when paired image processing like minimagick. I would also suggest your keep your rake tasks small in scope, write them to perform one task well, than chain tasks. I found very helpful for learning and working with rake http://jasonseifer.com/2010/04/06/rake-tutorial

atkolkma commented 11 years ago

Thanks guys. This is all great stuff!