Search code examples
perlwww-mechanize

How can I use Perl's WWW::Mechanize to check if a web page has been updated?


I'm using WWW::Mechanize to retrieve a webpage. I need to check if the page has been updated and retreive information from it. How can I do this?


Solution

  • Use the mirror method. This works fine for GET requests, see the method attribute of the form element which you are submitting. Just take note of the URI where you arrived, use it to repeatedly call mirror. Then there is no need to fill and submit the form anymore.

    In the case of POST, you are not able to leverage any assistance from the HTTProtocol (conditional requests, ETags and other cacheability features). You have to manually write out fetched results to files, then compare them.