[Haskell-cafe] Simple HTTP lib for Windows?
Yitzchak Gale
gale at sefer.org
Thu Jan 18 17:28:48 EST 2007
Alistair Bayley wrote:
>> I'd like to write a very simple Haskell script that when given a URL, looks
>> up the page, and returns a string of HTML. I don't see an HTTP library in
>> the standard libs...
Neil Mitchell wrote:
> MissingH?
MissingPy.
It would be great to have a full-featured native library that
handles all of the subtleties - redirects, cookies, etc.
But it could be that the most robust solution
currently is still the following:
(Using -package MissingPY)
import Python.Interpreter
import Python.Objects
main = do
py_initialize
pyImport "urllib2"
...
getHtml :: String -> IO String
getHtml url = do
urlObj <- toPyObject url
handle <- callByName "urllib2.urlopen" [urlObj] []
r <- getattr handle "read"
pyObject_Call r [] [] >>= strOf
Regards,
Yitz
More information about the Haskell-Cafe
mailing list