1

I am using Perl WWW::Mechanize::Chrome to automate a JS heavy website.

In response to a user click the page among many other requests, requests and loads a JSON file using XHR.

Is there some way to save this particular JSON data to a file?

3
  • 2
    You can record all requests as HAR.
    – daxim
    Commented Apr 11, 2018 at 9:29
  • The link speaks of keycodes and clicking on browser elements. I do not think these will be available from WWW::Mechanize::Chrome :( Commented Apr 13, 2018 at 9:22
  • stackoverflow.com/questions/68745624/… anyone know solution to this? Commented Sep 11 at 9:15

2 Answers 2

0

To intercept requests like that, you generally need to use the webRequest API to filter and retrieve specific responses. I do not think you can do that via WWW::Mechanize::Chrome.

1
  • 1
    A link to the relevant documentation would be quite useful. WWW::Mechanize::Chrome allows you to call API functions in Chrome, so there might be a way to do this. Effectively that's all the module does, so it should also just be a matter of subclassing and adding a call (or creating a PR and contributing).
    – simbabque
    Commented Apr 11, 2018 at 9:49
-1

WWW::Mechanize::Chrome tries to give you the content of all requests, but Chrome itself does not make the content of XHR requests available ( https://bugs.chromium.org/p/chromium/issues/detail?id=457484 ). So the approach I take in (for example ) Net::Google::Keep is to replay the XHR requests using plain Perl LWP requests by copying the cookies and parameters from the Chrome requests-

Please note that the official support forum for WWW::Mechanize::Chrome is https://perlmonks.org , not StackOverflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.