javascript - How to download an Html page and its internal files in android? -


i'm working on application needs download source of web page link, internal files, images, css, javascript.

after, need open html in webview, in offline mode, that's why need download page.

i'd download images using jsoup, haven't ideia how link them downloaded html.

could give me examples, or starting points start?

thanks in advance

essentially, you'll need (and app mentioned below does) go on references links additional additional assets / images / scripts , on, download them, , change html document point local downloaded copy. this, jsoup:

  • find img elements on page,

  • get location / url of image file src attribute of img elements (with .attr("abs:src:)),

  • download of images local directory

  • change each of image elements src attribute values point location of downloaded image file, relative main html file stored, eg .attr("src", "assets/imagefilename.png"").

  • do other assets required page, eg. images, css, scripts, html5 video, , others. did regex on css (both linked , inline) extract, download, , rewrite things background image references , in css. webpages have other linked things favicons or rss feeds might want too.

  • save jsoup document (with modified urls pointing downloaded versions of assets) file, calling .tostring() on , saving result file.

you can open local html file in webview, and, assuming have done right, show images , assets, offline.


i wrote android app this: save complete html file , of css / images / other assets local file / directory, using jsoup.

see https://github.com/jonascz/saveforoffline/ source, saveservice.java actual html page saving / downloading code.

beware it's gpl licensed, have comply gpl license if use (parts of) it.

also beware lot of things, , quite messy result, (there's no comments or documentation either...) may you.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -