Mechanize Cache problem

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

Hi,

On Fri, Sep 10, 2010 at 12:38 PM, Cameron V.
[email protected]wrote:

Mechanize instances do cache pages you’ve visited, but you can clear
that
with agent.history.clear; or prevent history from being saved by setting
agent.history.max_size = 0. Or, you can use a new Mechanize instance
altogether.

In the future, you may want to send Mechanize-specific questions to the
Mechanize mailing list:

http://rubyforge.org/mailman/listinfo/mechanize-users

Cheers,
-m


mike dalessio / [email protected] / http://mike.daless.io/ /
@flavorjones

So it is that easy!!

Thanks for the heads up.
I didn’t know that Machanize had a mailing list lol.
but this forum is really one of the best as far as a quality goes.

Thanks again

Mike D. wrote:

Hi,

On Fri, Sep 10, 2010 at 12:38 PM, Cameron V.
[email protected]wrote:

Mechanize instances do cache pages you’ve visited, but you can clear
that
with agent.history.clear; or prevent history from being saved by setting
agent.history.max_size = 0. Or, you can use a new Mechanize instance
altogether.

In the future, you may want to send Mechanize-specific questions to the
Mechanize mailing list:

http://rubyforge.org/mailman/listinfo/mechanize-users

Cheers,
-m


mike dalessio / [email protected] / http://mike.daless.io/ /
@flavorjones

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

sorry
is there a message edit?? lol
wrote that wrong on lat massage
“Cuz I hit refresh in IE and a new entry is shown…
I run my little search in Netbeans — doesn’t — show new entry…
repeat this for about 5 minutes eventual it shows new entry”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs