Hi, I had troubles with unfound links so I built a minimal example to reproduce the bug:
ancors.ml
module S = Soup
module M = Mechaml
let url = "https://fr.wikipedia.org/wiki/OCaml"
module Debug = struct
let pretty_print page css_selector =
let soup = M.Page.soup page in
let node = S.R.select_one css_selector soup in
print_endline (S.pretty_print node)
end
let action () =
let open M.Agent.Monad.Infix in
M.Agent.get url
>|= (fun http_res ->
let page = M.Agent.HttpResponse.page http_res in
let infobox_selector = ".infobox_v2 > tbody" in
(* select all descendants of the infobox *)
let link_selector = Printf.sprintf "%s *" infobox_selector in
(* checks that selector find first child element of infobox *)
Debug.pretty_print page link_selector;
(* is supposed to collect all links in the infobox *)
let link_seq = M.Page.links_with link_selector page in
let l = M.Page.to_list link_seq in
(* prints 0, while there is ~25 links in infobox *)
print_int (List.length l);
print_newline ())
let () = snd (M.Agent.Monad.run (M.Agent.init ()) (action ()))
dune
(executable (name ancors)
(libraries lambdasoup mechaml))
My version of Mechamel is 1.2.1.
I do not know what is the problem, maybe relative links ? I hope I did not make a trivial usage mistake of the library though. As a supplementary information, if I try to select all links of this page, I get about a list of length ~500.
Best,
Hi, I had troubles with unfound links so I built a minimal example to reproduce the bug:
ancors.ml
dune
My version of Mechamel is 1.2.1.
I do not know what is the problem, maybe relative links ? I hope I did not make a trivial usage mistake of the library though. As a supplementary information, if I try to select all links of this page, I get about a list of length ~500.
Best,