List Info

Thread: "ocaml_beginners"::[] getting html files




"ocaml_beginners"::[] getting html files
user name
2006-12-09 05:03:17

2006/12/9, jshaw10 < jshaw10%40yahoo.com">jshaw10yahoo.com>:
>; Suppose I want to get the index.html from finance.yahoo.com. Following
> the guidance from these sites
>;
> http://www.jmarshall.com/easy/http/
>; http://web-sniffer.net/
>
> I learned that the following should work:
>;
> Printf.fprintf
> outchan
&gt; "GET / %s"
> "HTTP/1.1rnHost: finance.yahoo.comrnConnection: closernAccept:
[...]
>
>; However this always gives me an error 400 - ie yahoo does not have
> that resource. I've also tried reducing the get request to "GET /
> HTTP/1.1rnrn". Any hints?

It's strange, it work here... How do you built outchan ?

By the way, there exist library for http in ocaml, why don't you use them ?
look for exemple at http://www.ocaml-programming.de/programming/netclient.html

__._,_.___
.

__,_._,___
"ocaml_beginners"::[] getting html files
user name
2006-12-09 16:01:40

A full fledged http client is more than I need. I can do what I need
in just a few lines of code once I read the file from the http server.
Besides, it's fun to know how things work.

Here's how I create the socket:

let financeaddr = Unix.ADDR_INET (Unix.inet_addr_of_string
&quot;68.142.196.87", 80) in
let s = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in
Unix.connect s financeaddr;
let inchan = Unix.in_channel_of_descr s in
let outchan = Unix.out_channel_of_descr s in

__._,_.___
.

__,_._,___
"ocaml_beginners"::[] getting html files
user name
2006-12-09 17:36:54

Thanks for confirming that it actually works.

I just tried it on a mac and it worked fine. I have no idea what the
difference was, but I'll try it on the windows machine again later and
see if I can make it work.

__._,_.___
.

__,_._,___
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )