[android-developers] Re: How do I save a complete webpage displayed in Android's WebView?

2012-06-20 Thread gjs
Hi,

No quite what you are looking for but you can save the entire
(rendered) web page as an image to view offline.

See a very old post of mine that show how to do this, in older
versions of Android  -

https://groups.google.com/group/android-developers/browse_thread/thread/5bab2668cd5ab44f/81651cbd13bc6faa?lnk=gst&q=gjs+yahoo#81651cbd13bc6faa

You could save the page as an image & also the url to view the page
online again later.

Regards

On Jun 21, 11:32 am, imsproject ims  wrote:
> Hi Nobu Games,
>
> Thanks for your reply.  I will try using javascript as you mentioned.
>
> Thanks,
>
> On Wed, Jun 20, 2012 at 6:10 PM, Nobu Games wrote:
>
>
>
>
>
>
>
> > I just found a simpler example without JavaScript to Android interface:
>
> >http://lexandera.com/2009/01/extracting-html-from-a-webview/
>
> > Above link also shows how to implement your own WebViewClient class to
> > control some basic WebView behavior.
>
> >  --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How do I save a complete webpage displayed in Android's WebView?

2012-06-20 Thread imsproject ims
Hi Nobu Games,

Thanks for your reply.  I will try using javascript as you mentioned.

Thanks,

On Wed, Jun 20, 2012 at 6:10 PM, Nobu Games wrote:

> I just found a simpler example without JavaScript to Android interface:
>
> http://lexandera.com/2009/01/extracting-html-from-a-webview/
>
> Above link also shows how to implement your own WebViewClient class to
> control some basic WebView behavior.
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How do I save a complete webpage displayed in Android's WebView?

2012-06-20 Thread Nobu Games
I just found a simpler example without JavaScript to Android interface:

http://lexandera.com/2009/01/extracting-html-from-a-webview/

Above link also shows how to implement your own WebViewClient class to 
control some basic WebView behavior.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How do I save a complete webpage displayed in Android's WebView?

2012-06-20 Thread Nobu Games
Oh my, JavaScript indeed slipped my mind for a second. But this is also not 
the only problem because a lot of web pages are generated on a per-user 
basis, so one and the same URL won't look like the same on another client 
(think of logins).

Anyway. You could inject JavaScript into the WebView that displays the 
website you want to copy. This can be done by setting a URL on the WebView 
which is prefixed with the "javascript:" protocol followed by the "trojan" 
JavaScript code.

Use your JavaScript code to serialize a copy of the DOM node tree and pass 
that information over to your app. You can write an Android interface which you 
can call from 
JavaScriptwithin
 a WebView.

I am unfortunately not familiar with that Pocket app so I don't know what 
it exactly does.


On Wednesday, June 20, 2012 7:30:17 PM UTC-5, VP wrote:
>
> Hi Nobu Games,
>
> Thanks for your reply. However I already tried using the user-agent string 
> returned by Android to download content from URL. This however did not work 
> since the returned webpage says that javascript is not enabled on your 
> browser. I tried on url: www.techcrunch.com and www.cnet.com.
>  
> The use case of my application is as follows:
>
> The user uses any third party application (like News reader/Pulse etc) to 
> read some content and want to share. He shares the URL link of this content 
> with my application. Here I want to download this web-content and upload it 
> to some server. However I cannot use HTTP GET method to download the 
> content since it does not return proper content of the URL. Hence I am 
> using WebView to render/download this content. Now I want to save this 
> content displayed in the WebView and upload it to some server.
>
> Basically my requirement is the same as the Pocket (Readitlater 
> http://getpocket.com/). I want to save a webpage for offline consumption.
>
>
> Is there a way to achieve this? 
>
> Thanks,
>
>
> On Wed, Jun 20, 2012 at 5:08 PM, Nobu Games wrote:
>
>> You can retrieve the user agent 
>> stringfrom
>>  the WebView. Add that string as a user agent header to your request
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How do I save a complete webpage displayed in Android's WebView?

2012-06-20 Thread imsproject ims
Hi Nobu Games,

Thanks for your reply. However I already tried using the user-agent string
returned by Android to download content from URL. This however did not work
since the returned webpage says that javascript is not enabled on your
browser. I tried on url: www.techcrunch.com and www.cnet.com.

The use case of my application is as follows:

The user uses any third party application (like News reader/Pulse etc) to
read some content and want to share. He shares the URL link of this content
with my application. Here I want to download this web-content and upload it
to some server. However I cannot use HTTP GET method to download the
content since it does not return proper content of the URL. Hence I am
using WebView to render/download this content. Now I want to save this
content displayed in the WebView and upload it to some server.

Basically my requirement is the same as the Pocket (Readitlater
http://getpocket.com/). I want to save a webpage for offline consumption.


Is there a way to achieve this?

Thanks,


On Wed, Jun 20, 2012 at 5:08 PM, Nobu Games wrote:

> You can retrieve the user agent 
> stringfrom
>  the WebView. Add that string as a user agent header to your request
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How do I save a complete webpage displayed in Android's WebView?

2012-06-20 Thread Nobu Games
You can retrieve the user agent 
stringfrom
 the WebView. Add that string as a user agent header to your request

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How do I save a complete webpage displayed in Android's WebView?

2012-06-20 Thread imsproject ims
Hello,
Thanks for your reply. However using of HTTP GET request does not download
the exact content that you will see on the WebView. Many websites
especially technical article sites, send content based on the browser and
whether JavaScript is enabled or not.
Is there any other way of achieving this?

Thanks,

On Wed, Jun 20, 2012 at 12:45 PM, Nobu Games wrote:

> Write your own HTTP GET request component that downloads a web page,
> parses the HTML and searches it for linked documents and resources and
> download these.
>
> Maybe you'll find ready-made website crawler components on the web because
> this is a non-trivial task with lots of pitfalls like recursion and
> infinite loops during downloads or downloading the whole Internet because
> no reasonable limits are applied.
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How do I save a complete webpage displayed in Android's WebView?

2012-06-20 Thread imsproject ims
You are right. Also the public API for saving as web archive is only
available only for Android 3.x onwards. So parsing the archive is not an
option.
Is there any other way to save the html content displayed in a WebView?

Thanks,

On Wed, Jun 20, 2012 at 12:36 PM, Doug  wrote:

> I don't think you can do this with documented public APIs.  I wouldn't go
> reaching into that cache folder unless you have a very clear understanding
> of how that works in all versions of Android that you need to work with.
>
> Doug
>
>
> On Wednesday, June 13, 2012 11:55:53 AM UTC-7, VP wrote:
>>
>> I am developing an Android application in which I have a WebView. I want
>> to save the entire webpage loaded in this webview (Html + all resources +
>> images + icons etc) into a folder and zip it and upload it to a server.
>>
>> If you use WebView's 
>> saveWebArchive,
>> then it is saved in archive format. How do I get the Html and images back
>> from this archive? Is there any documentation for the format of this
>> archive?
>>
>> If I use addJavaScriptInterface to get the html as described 
>> here,
>> I still have to copy the images and other resources from the webview cache
>> dir (/data/data/your app package/cache/webviewCache/). However I did not
>> find webview cache dir (/data/data/your app package/cache/webviewCache/) in
>> Icecream Sandwich.
>>
>> Is there a way to save the entire webpage displayed in webview along with
>> resources in Android? Can somebody please help. I have to ship this feature
>> ASAP.
>>
>> Thanks
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: How do I save a complete webpage displayed in Android's WebView?

2012-06-20 Thread Nobu Games
Write your own HTTP GET request component that downloads a web page, parses 
the HTML and searches it for linked documents and resources and download 
these. 

Maybe you'll find ready-made website crawler components on the web because 
this is a non-trivial task with lots of pitfalls like recursion and 
infinite loops during downloads or downloading the whole Internet because 
no reasonable limits are applied.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: How do I save a complete webpage displayed in Android's WebView?

2012-06-20 Thread Doug
I don't think you can do this with documented public APIs.  I wouldn't go 
reaching into that cache folder unless you have a very clear understanding 
of how that works in all versions of Android that you need to work with.

Doug

On Wednesday, June 13, 2012 11:55:53 AM UTC-7, VP wrote:
>
> I am developing an Android application in which I have a WebView. I want 
> to save the entire webpage loaded in this webview (Html + all resources + 
> images + icons etc) into a folder and zip it and upload it to a server. 
>
> If you use WebView's 
> saveWebArchive,
>  
> then it is saved in archive format. How do I get the Html and images back 
> from this archive? Is there any documentation for the format of this 
> archive? 
>
> If I use addJavaScriptInterface to get the html as described 
> here, 
> I still have to copy the images and other resources from the webview cache 
> dir (/data/data/your app package/cache/webviewCache/). However I did not 
> find webview cache dir (/data/data/your app package/cache/webviewCache/) in 
> Icecream Sandwich. 
>
> Is there a way to save the entire webpage displayed in webview along with 
> resources in Android? Can somebody please help. I have to ship this feature 
> ASAP.
>
> Thanks 
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en