[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: `wget' web site



On Sun, Sep 26, 2021 at 5:18 AM Rodolfo Medina <rodolfo.medina@gmail.com> wrote:
>
> Hi all.
>
> I manage to download an entire website, say www.mysite.com, with simply
>
>  $ wget -r -l 0 www.mysite.com
>
> After that, I can surf that web site offline with all its internal links.
> Perfect.
>
> Now the problem comes when I want to copy that stuff into my Android tablet and
> read it offline too.  Then the links do not work any more.
>
> Any suggestions?
>

That's because in Android 7+, when you open a file in any app through
the file manager
that opened app doesn't have access to the "file path" of that file.
it just gets the file descriptor of that file and accesses it as a stream.

when you open a downloaded website (bunch of html,js,css files in hierarchy).
you open a single html file(index.html) and click on hyperlinks(file
paths resolved relatively against index.html) to browse the website
from there on.
Since the browser in your desktop gnu/linux system has direct access
to file paths, it can resolve them and you can browse them easily.
But when open that same index.html file in android the file manager
sends an intent(request containing URI,file mime-type,perms)
requesting android system to resolve that file(.html file)
against installed apps, android system checks whether the any
installed app can open this type(mime-type) of file or not,
if there are multiple apps(mostly browsers) installed that can open
html files it asks user to choose one app(that just once and always
dialog),
since the browser can open html files it sends that intent to the
browser(or to the app you selected if there are multiple ones).
the browser checks the intent and resolves the URI in the intent(by
asking android system), the request gets passed back to the file
manager's Content provider,
that is why you see "content:://" type url in browser and not
"file://" as in desktop browser,then
the file manager content provider sends back a file descriptor of that
requested file(index.html) back to browser,
which then gets open as plain  html file because the css files,assets
cant be resolved from that URI

Solution is to use some app that can open offline websites  directly
from local storage
using storage permission and not through file manager apps unless you
have an android 6 or below device.

https://developer.android.com/about/versions/nougat/android-7.0-changes#sharing-files


Reply to: