2010-11-29 07:01:05
// Learn more about F# at http://fsharp.net
open System
open System.IO
open System.Net
open System.Text.RegularExpressions
 
let path = Environment.SpecialFolder.Desktop;
 
let Download (link:string) = 
    let uri = new System.Uri(link)
    let webClient = new WebClient()
    webClient.Headers.Add("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")
    let data = webClient.DownloadString(uri)
    data
 
let text = "hello world";
let data = Download("http://www.google.com.sg/search?hl=en&source=hp&biw=&bih=&q=" + text + "&btnG=Google+Search&aq=f&aqi=&aql=&oq=" + text + "&gs_rfai=&fp=5664261d3c1a586b")
 
let Search text = 
    let url = "http://www.google.com.sg/search?hl=en&source=hp&biw=&bih=&q=" + text + "&btnG=Google+Search&aq=f&aqi=&aql=&oq=" + text + "&gs_rfai=&fp=5664261d3c1a586b"
    async {
        let req = new WebClient()
        let! result = req.AsyncDownloadString(new Uri(url))
        printf "%s done %d\n" text (result.Length)
        return result.Length
    }
 
let totalChars = ["hello"; "world"; "hello world"] |> List.map Search |> Async.Parallel |> Async.RunSynchronously |> Array.fold (+) 0
printf "Total loaded %d\n" totalChars
 
Invalid Email or Password