An F# HelloWorld Style Crawler / Scraper (if you may)#
I wrote/scavenge this while Amanda Laucher's F# talk yesterday. It's a beauty, this terse F# syntactically & semantically. Having worked with scheme, experimenting with F# comes naturally however James Iry during a 1-1 discussions begs to differ that they are QUITE different. I have yet to independently verify the merit of this claim.

open System.IO
open System.Net            
            
let GetUrl(url:string) =

    let req = WebRequest.Create(url)

    // Get the response, synchronously
    let rsp = req.GetResponse()

    // Grab the response stream and a reader. Clean up when we're done
    use stream = rsp.GetResponseStream()
    use reader = new StreamReader(stream)

    // Synchronous read-to-end, returning the result
    reader.ReadToEnd()

let result = GetUrl("http://www.google.com")
printfn "%s" result





10/26/2008 5:43:32 AM (Pacific Standard Time, UTC-08:00) #    Comments [1]  |  Trackback
Tracked by:
"Interesting Finds: October 26, 2008" (Jason Haley) [Trackback]

 

All content © 2010, Adnan Masood
About the Author
On this page
Calendar
<February 2010>
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
28123456
78910111213
Archives
Sitemap
Blogroll OPML
microsoft
Blogroll
Disclaimer

Powered by: newtelligence dasBlog 1.8.5223.2

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts