1

There is a small web app that I want to scrape. It loads various json snippets into a panel on the page when you click on a tree widget. I estimate that there are no fewer than about 500 such json files. I've managed to figure out how to grab those, and I was hoping that I could simply place those in the appropriate folder and the xhr calls would retrieve them.

As it is, I receive this particular error message when clicking on my offline version of the webapp:

XMLHttpRequest cannot load file:///json/ajaxbrowse.php?n=5&x=1&z=-1&cs=1&ix=-1. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource

Is there a way to accomplish the loading of external files here without a web app (or disabling Chrome security features)? The html file and the json files live in the same folder. Given their format (json), I can't easily load these into iframes.

Googling's not showing me much for this, and I'm not sure what javascript/browser feature I might be searching for.

John O
  • 4,863
  • 8
  • 45
  • 78
  • XHR will not fetch local files even if the page is loaded as a local file. However you can still use the File API to read local files with a few user actions. – Derek 朕會功夫 Aug 24 '16 at 21:26
  • Everything's minified pretty bad. Not sure I can monkey patch it to use that. – John O Aug 24 '16 at 21:38
  • Why not just run a simple local web server? `python -m SimpleHTTPServer` or something. And why do you need to operate on an offline copy of the web app? Why not just scrape the content from the existing app wherever it actually lives on the web? – sideshowbarker Aug 25 '16 at 01:27
  • Because I'd like to be able to hand someone the html file, have them run it without going through 4 hours of setup. – John O Aug 25 '16 at 05:09
  • Look for: https://stackoverflow.com/a/18137280/2895579 – evg656e Jul 07 '17 at 15:17
  • Possible duplicate of [Chrome allow file access from files no longer working (was using to see WebGL/three.js files)?](https://stackoverflow.com/questions/24826544/chrome-allow-file-access-from-files-no-longer-working-was-using-to-see-webgl-th) – Paul Sweatte Sep 12 '17 at 05:04

0 Answers0