I'm using Mechanize to grab a bunch of pages behind links. On page A, there's a bunch of companies that have a link called "[complete profile]", behind which is full html I want to grab. There are 10 of these on page A. I can't seem to traverse the links and save them into an array, then use them later. So, I might as well iterate through each link, grab the url and the company HTML at the same time. I was planning on storing them and resorting to them, but they are not full links and I don't know how it is done.
Anyway, this is what I currently have:
companyobjects = agent.page.links_with(:text => '[complete profile]')
companylinks = []
companyobjects.each do |i|
companylinks.push(i)
# -> Shove each company's html into the db
page = agent.i.href.click
puts
puts page
end
The page = agent.i.href.click is where things go wrong. 'i' should be an individual company, so asking for its internal link and clicking on it should get the page, but it's not getting past "method 'i'" for some reason.
Anybody know how to grab found links and grab the html behind them? I'm lost. Any input appreciated.
Cheers