Created
January 13, 2013 07:48
-
-
Save ichiban/4522877 to your computer and use it in GitHub Desktop.
たった20行のコードでひたすらアイドル水着画像を集める(OCamlだよ)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ocamlscript | |
Ocaml.packs := ["batteries"; "netclient"] | |
-- | |
open BatPervasives | |
open Str | |
open Http_client.Convenience | |
let url = "http://matome.naver.jp/odai/2135350364969742801" | |
let pattern = regexp "<img src=\".+\".*class=\"MTMItemThumb\".*/>" | |
let search pattern str = | |
let aux offset = | |
try | |
let offset' = search_forward pattern str offset | |
in Some (matched_string str, offset' + 1) | |
with Not_found -> None | |
in BatEnum.unfold 0 aux | |
let () = | |
http_get url |> search pattern |> iter print_string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment