save webpages for offline browsing

Deadly 提交于 2019-12-24 12:51:17

问题


i am trying to create an android application that saves webpages to use it in offline-browsing, i was able to save the webpage but the problem was in the contents (images, javascripts,..etc), is there a way to do so programmatically, i use eclipse and test my work on an emulator.


回答1:


hm, I am afraid you should parse html's yourself (I mean do that with a properly lib) and store all resources (css, js, images, videos etc.) too. s. how it is done in a java crawler: open source crawlers




回答2:


You will need to search for all images, javascript files, css files, etc... and download them, saving them to the same relative path to the HMTL files - Assuming the html is coded with relative paths (images/image.png) and not absolute paths (http://www.domain.com/image/image.png).

You can pretty easily search the html string for <img, <script, <link etc.. and parse from there - or you can find a 3rd party html parser



来源:https://stackoverflow.com/questions/4563291/save-webpages-for-offline-browsing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!