joshim5
joshim5

Reputation: 2255

Ruby access/submit queries on websites

Say I wanted to create a ruby script that would access google, search for 'dogs', and then return the links of the top 5 results. How would this be implemented in ruby? Thanks.

To clarify, I'm not looking for a way to search Google specifically. I want this to work on other sites too, such as amazon.com, dictionary.com, etc.

Upvotes: 0

Views: 203

Answers (3)

Brian Clapper
Brian Clapper

Reputation: 26210

See the answer to this question: Using Google Search REST API in Ruby

Upvotes: 1

pjammer
pjammer

Reputation: 9577

You could hack through it with hpricot, if a google api doesn't exist already. Or here is a script

Upvotes: 0

sethvargo
sethvargo

Reputation: 26997

I would use cURL to actually GET the page contents (its a simple GET request to google.com/?q=stuff). Then you'll need to use regular expressions and intuition to parse the DOM, extract the links, and display :)

Upvotes: 0

Related Questions