Mechanize Cache problem

C

Cameron Vessey

Hi
ok hears the deal, I'm building a program that notify's you when theres
a new entry on a webpage. Problem is my mechanize results seems to be
about 10 minutes behind!

Mechanize is not returning the most current state of the website. Now
eventually it will show the changes, but even then it's still way
behind. So is this a cacheing problem? Does any one know of a "
agent.clear" method or something so that I can clear Mechanizes cache
every time?

Thanks
 
C

Cameron Vessey

Wait wait ... Got back into my code.. as far as I can tell every time I
call for Mechanize to search the page it is doing it with a new instance
of agent.
So its probable not a caching problem.
Because right now I don't even have the repeated search loop built ..
I'm running it singularly ... and then running it again .. so the
results are froma new agent instance every time ... hhhmmm..

Cuz I hit refresh in IE and a new entry is shown...
I run my little search in Netbeans does show new entry.. repeat this for
about 5 minutes eventual it shows new entry

heres the code if your interesed ...but I'l go ask the Mechanize guys



def search(search_url)
results = []
agent = Mechanize.new
page = agent.get(search_url)

until page.links[0].text =~ /Next >>/

page.links.delete_at(0)
end
page.links.delete_at(0)
while page.links[0].text =~ /^\d{1,}\z/

page.links.delete_at(0)
end
page.links.each{|l|
results << l
}
return results
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top