Web scraping/OCaml: Difference between revisions

m
(implementation for making http requests in OCaml)
 
 
(2 intermediate revisions by 2 users not shown)
Line 1:
The content of this page is related to the main page [[Web Scraping#OCaml]]
 
<lang ocaml>
let init_socket addr port =
let inet_addr = (Unix.gethostbyname addr).Unix.h_addr_list.(0) in
Line 13:
 
let serialize ~post_data =
String.concat "&"
let rec aux acc = function
|(List.map (fun (key, var)::[] -> acckey ^ (key^"=" ^ var) post_data)
| [] -> acc
| (key,var)::[] -> acc ^ (key^"="^var)
| (key,var)::tail -> aux (acc ^ key^"="^var^"&") tail
in
aux "" post_data
;;
 
Line 134 ⟶ 130:
(cont)
;;
</ocamllang>
Anonymous user