Skip to content

Instantly share code, notes, and snippets.

Created Jul 4, 2019
What would you like to do?
A simple scraper
#r "fsharp-data/lib/net45/FSharp.Data.dll"
open FSharp.Data
let doc = HtmlDocument.Load("")
let posts = doc.CssSelect(".single-article")
let firstChildText selector (post : HtmlNode) =
let cleanName (name : string) = name.Replace("", "")
let top3 =
|> post ->
post |> firstChildText ".content h3",
post |> firstChildText "h4 > a" |> cleanName,
post |> firstChildText ".reactions-count .engagement-count-number")
|> Seq.take 3
for (title, author, reactions) in top3 do
printf "\"%s\" (%s): %s\n" title author reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment