Skip to content

Instantly share code, notes, and snippets.

@stdray
Created January 8, 2015 22:33
Show Gist options
  • Save stdray/ddcac8423597efe0379f to your computer and use it in GitHub Desktop.
Save stdray/ddcac8423597efe0379f to your computer and use it in GitHub Desktop.
let nakruto4ka id last count =
use http = new System.Net.Http.HttpClient()
http.BaseAddress <- System.Uri @"http://facemash.polotsk-portal.ru/rate.php"
http.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0")
http.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
http.DefaultRequestHeaders.Add("Accept-Language", "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3")
http.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate")
http.DefaultRequestHeaders.Add("Referer", "http://facemash.polotsk-portal.ru/")
let rng = System.Random()
Seq.initInfinite (fun _ -> rng.Next(1, last))
|> Seq.map (fun v -> if v = id then ~~~v else v)
|> Seq.take count
|> Seq.map (sprintf "?winner=%d&loser=%d" id >> http.GetAsync >> Async.AwaitTask)
|> Async.Parallel
|> Async.RunSynchronously
|> Seq.countBy (fun r -> r.StatusCode)
|> Map.ofSeq
//http://facemash.polotsk-portal.ru/rate.php?winner=873&loser=917
nakruto4ka 873 20000 100 |> printfn "Statistika %A"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment