How to programmatically save a web-page using R (mimicking Command+S)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to programmatically save a web-page using R (mimicking Command+S)

Bogaso
Hi,

I would appreciate if someone can give me a pointer on how to save a
webpage programmatically using R.

For example, let say I have this webpage open in my browser:

http://www.bseindia.com/stock-share-price/dabur-india-ltd/dabur/500096/

When manually I save this page, I just press Command+S (using Mac) and
then this page get saved in hard-disk

Now I want R to mimic this same job that I do using Command-S

So far I have tried with readLines() however the output content is
different than what I could achieve using Command+S

Any help will be highly appreciated.

Thanks for your time.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to programmatically save a web-page using R (mimicking Command+S)

Henrik Bengtsson-5
The 'webshot' package (on CRAN) can do this.

Henrik

On Jan 6, 2018 05:27, "Christofer Bogaso" <[hidden email]>
wrote:

> Hi,
>
> I would appreciate if someone can give me a pointer on how to save a
> webpage programmatically using R.
>
> For example, let say I have this webpage open in my browser:
>
> http://www.bseindia.com/stock-share-price/dabur-india-ltd/dabur/500096/
>
> When manually I save this page, I just press Command+S (using Mac) and
> then this page get saved in hard-disk
>
> Now I want R to mimic this same job that I do using Command-S
>
> So far I have tried with readLines() however the output content is
> different than what I could achieve using Command+S
>
> Any help will be highly appreciated.
>
> Thanks for your time.
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to programmatically save a web-page using R (mimicking Command+S)

Bogaso
Hi Henrik,

Thanks for your pointer. Saving via PDF is working for me, however, in
many cases, it is unusually taking a long time.

In many cases I am facing Error too as below. This is particularly
occurring if I trigger Multicore calculation option

webshot.js returned failure value: 1

Just wondering if there is any other direct ways to achieve the same.

Thanks,

On Sat, Jan 6, 2018 at 7:14 PM, Henrik Bengtsson
<[hidden email]> wrote:

> The 'webshot' package (on CRAN) can do this.
>
> Henrik
>
> On Jan 6, 2018 05:27, "Christofer Bogaso" <[hidden email]>
> wrote:
>>
>> Hi,
>>
>> I would appreciate if someone can give me a pointer on how to save a
>> webpage programmatically using R.
>>
>> For example, let say I have this webpage open in my browser:
>>
>> http://www.bseindia.com/stock-share-price/dabur-india-ltd/dabur/500096/
>>
>> When manually I save this page, I just press Command+S (using Mac) and
>> then this page get saved in hard-disk
>>
>> Now I want R to mimic this same job that I do using Command-S
>>
>> So far I have tried with readLines() however the output content is
>> different than what I could achieve using Command+S
>>
>> Any help will be highly appreciated.
>>
>> Thanks for your time.
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to programmatically save a web-page using R (mimicking Command+S)

Enrico Schumann-2
In reply to this post by Bogaso
On Sat, 06 Jan 2018, Christofer Bogaso writes:

> Hi,
>
> I would appreciate if someone can give me a pointer on how to save a
> webpage programmatically using R.
>
> For example, let say I have this webpage open in my browser:
>
> http://www.bseindia.com/stock-share-price/dabur-india-ltd/dabur/500096/
>
> When manually I save this page, I just press Command+S (using Mac) and
> then this page get saved in hard-disk
>
> Now I want R to mimic this same job that I do using Command-S
>
> So far I have tried with readLines() however the output content is
> different than what I could achieve using Command+S
>
> Any help will be highly appreciated.
>
> Thanks for your time.
>

The command-line utility 'wget' can download websites,
including graphics, etc. Look for 'mirror' in its
documentation if you want to download the complete
site. It is usually available by default on Unix-style
systems; I am sure there is a version for Mac. If you
insist on using R, you could write a simple wrapper,
using ?system or ?system2.


--
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.