Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #r @"..\packages\FSharp.Data.2.2.5\lib\net40\FSharp.Data.dll"
- open FSharp.Data
- open System.Text.RegularExpressions
- let alphabet = ["a"; "b"; "v"; "g"; "d"; "e"; "jo"; "zh"; "z"; "i"; "k"; "l"; "m"; "n"; "o"; "p"; "r"; "s"; "t"; "u"; "f"; "kh"; "c"; "ch"; "sh"; "shch"; "eh"; "ju"; "ja"]
- let getUri = sprintf "http://old-abiturient.urfu.ru/applicant/master-2015/alpha/%s/"
- type Spec = {Title: string; Priority: int}
- type Abiturient = {Name: string; N: string; Spec: Spec list}
- let peoples = alphabet
- |> List.take 1
- |> List.map getUri
- |> List.map HtmlDocument.Load
- |> List.collect (fun x -> x.Descendants "table"
- |> Seq.exactlyOne
- |> fun t -> t.Elements "tr"
- |> Seq.skip 1
- |> Seq.fold
- (fun (accList, tempList, hClass) e ->
- match e.AttributeValue "class" with
- | c when c = hClass -> (accList, e.Elements () :: tempList, hClass)
- | c -> (tempList :: accList, [e.Elements ()], c)) ([[]], [], "tr-even")
- |> fun (c, _, _) -> c |> List.rev |> List.map List.rev
- |> List.tail
- |> List.map
- (fun nodes -> {Name = nodes.[0].[0].InnerText (); N = nodes.[0].[1].InnerText ();
- Spec = [{Title = nodes.[0].[5].InnerText (); Priority = 0}]
- @ (nodes
- |> List.skip 1
- |> List.mapi (fun i n-> {Title = n.[3].InnerText (); Priority = i + 1}))}
- )
- )
- |> List.filter (fun ab -> ab.Spec |> List.exists (fun spec -> spec.Title.Contains "ИМКН"))
- printf "%A" peoples.[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement