download a remote file

15 views
Skip to first unread message

Damien Mattei

unread,
Feb 9, 2017, 3:07:09 AM2/9/17
to BiwaScheme
Hi,

is there a way to download a remote file in BiwaScheme having is URL.
This is for getting an html page that will be parsed to construct a menu list in another page.
The job will be done in the browser not on server side.

regards,
Damien

Yutaka Hara

unread,
Feb 11, 2017, 12:30:08 PM2/11/17
to biwas...@googlegroups.com
Hi,

There is a function named `http-request'. It takes the path to the remote file, fetches
its content and returns it as a string. For example, this will show the content of index.html
in the developer console.

(console-log (http-request "index.html"))

--
You received this message because you are subscribed to the Google Groups "BiwaScheme" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biwascheme+unsubscribe@googlegroups.com.
To post to this group, send email to biwas...@googlegroups.com.
Visit this group at https://groups.google.com/group/biwascheme.
For more options, visit https://groups.google.com/d/optout.



--
Yutaka HARA

Damien Mattei

unread,
Feb 11, 2017, 1:47:53 PM2/11/17
to biwas...@googlegroups.com
thanks you,
i didn't saw it was in the Ajax section of documentation,
thanks a lot for your help and your Scheme,
regards,
damien

On Sat, Feb 11, 2017 at 6:29 PM, Yutaka Hara <yutak...@gmail.com> wrote:
> Hi,
>
> There is a function named `http-request'. It takes the path to the remote
> file, fetches
> its content and returns it as a string. For example, this will show the
> content of index.html
> in the developer console.
>
> (console-log (http-request "index.html"))
>
> 2017-02-09 17:07 GMT+09:00 Damien Mattei <damien...@gmail.com>:
>>
>> Hi,
>>
>> is there a way to download a remote file in BiwaScheme having is URL.
>> This is for getting an html page that will be parsed to construct a menu
>> list in another page.
>> The job will be done in the browser not on server side.
>>
>> regards,
>> Damien
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "BiwaScheme" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to biwascheme+...@googlegroups.com.
>> To post to this group, send email to biwas...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/biwascheme.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Yutaka HARA
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "BiwaScheme" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/biwascheme/ofBUsLP2_nQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> biwascheme+...@googlegroups.com.

Damien Mattei

unread,
Mar 3, 2017, 9:41:48 AM3/3/17
to biwas...@googlegroups.com
Hi,

i try to use it in a real example , i can see in the javascript
console of web browser that it succeeded in isuuing a GET command and
fetched the remote file but then i cannot display the string or even
display the string-length ???
here is my example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>BiwaScheme example</title>
</head>
<body>
<div id="bs-console">
</div>
<script src="biwascheme.js">
(print "Hello, world!")
(print (current-date))
;;(define wp (http-request
"http://ad.usno.navy.mil/wds/Webtextfiles/wdsnewref.txt"))
(define wp "the string")
;;(define wp (http-request "https://sidonie2.oca.eu/Sidonie/Default.htm"))
(print (string-length wp))
(set! wp (http-request
"http://ad.usno.navy.mil/wds/Webtextfiles/wdsnewref.txt"))
(print (string-length wp))
(print "---------------------------")
(console-log "ok.")
</script>
</body>
</html>

here is my output:
Hello, world!
Fri Mar 03 2017 15:40:15 GMT+0100 (CET)
10

nothing more!

regards,
damien
On 2/11/17, Yutaka Hara <yutak...@gmail.com> wrote:
> Hi,
>
> There is a function named `http-request'. It takes the path to the remote
> file, fetches
> its content and returns it as a string. For example, this will show the
> content of index.html
> in the developer console.
>
> (console-log (http-request "index.html"))
>
> 2017-02-09 17:07 GMT+09:00 Damien Mattei <damien...@gmail.com>:
>
>> Hi,
>>
>> is there a way to download a remote file in BiwaScheme having is URL.
>> This is for getting an html page that will be parsed to construct a menu
>> list in another page.
>> The job will be done in the browser not on server side.
>>
>> regards,
>> Damien
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "BiwaScheme" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to biwascheme+...@googlegroups.com.
>> To post to this group, send email to biwas...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/biwascheme.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Yutaka HARA
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "BiwaScheme" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/biwascheme/ofBUsLP2_nQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> biwascheme+...@googlegroups.com.

Yutaka Hara

unread,
Mar 8, 2017, 1:29:22 AM3/8/17
to biwas...@googlegroups.com
Hi,

With google chrome, I got this error in the developer console:

> XMLHttpRequest cannot load http://ad.usno.navy.mil/wds/Webtextfiles/wdsnewref.txt. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

For security reason, Ajax requests are restricted to the same domain name as the domain of the JavaScript page
(unless explicitly allowed by the server:
In other words, your code and data must be on the same server.


>> To post to this group, send email to biwas...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/biwascheme.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Yutaka HARA
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "BiwaScheme" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/biwascheme/ofBUsLP2_nQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to

> To post to this group, send email to biwas...@googlegroups.com.
> Visit this group at https://groups.google.com/group/biwascheme.
> For more options, visit https://groups.google.com/d/optout.
>

--
You received this message because you are subscribed to the Google Groups "BiwaScheme" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biwascheme+unsubscribe@googlegroups.com.

To post to this group, send email to biwas...@googlegroups.com.
Visit this group at https://groups.google.com/group/biwascheme.
For more options, visit https://groups.google.com/d/optout.



--
Yutaka HARA

Damien Mattei

unread,
Mar 8, 2017, 2:10:28 AM3/8/17
to biwas...@googlegroups.com
thanks you,
i also come to the same conclusions few days ago...
regards,
damien
>> >> email to biwascheme+...@googlegroups.com.
>> >> To post to this group, send email to biwas...@googlegroups.com.
>> >> Visit this group at https://groups.google.com/group/biwascheme.
>> >> For more options, visit https://groups.google.com/d/optout.
>> >>
>> >
>> >
>> >
>> > --
>> > Yutaka HARA
>> >
>> > --
>> > You received this message because you are subscribed to a topic in the
>> > Google Groups "BiwaScheme" group.
>> > To unsubscribe from this topic, visit
>> > https://groups.google.com/d/topic/biwascheme/ofBUsLP2_nQ/unsubscribe.
>> > To unsubscribe from this group and all its topics, send an email to
>> > biwascheme+...@googlegroups.com.
>> > To post to this group, send email to biwas...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/biwascheme.
>> > For more options, visit https://groups.google.com/d/optout.
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "BiwaScheme" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to biwascheme+...@googlegroups.com.
>> To post to this group, send email to biwas...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/biwascheme.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Yutaka HARA
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "BiwaScheme" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/biwascheme/ofBUsLP2_nQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> biwascheme+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages