added first browser tests
This commit is contained in:
parent
4df1d9c09f
commit
b9368ee154
2 changed files with 23 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
*.hi
|
*.hi
|
||||||
*.o
|
*.o
|
||||||
cnb
|
cnb
|
||||||
|
browser
|
||||||
|
|
22
browser.hs
Normal file
22
browser.hs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
|
import Network.HTTP.Conduit
|
||||||
|
import qualified Data.ByteString.Lazy as L
|
||||||
|
import qualified Data.ByteString.Char8 as C
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = do
|
||||||
|
b <- getTweet "https://twitter.com/YELLEtweets/status/535845076316860417"
|
||||||
|
case b of
|
||||||
|
Nothing -> putStrLn "nothing to pring"
|
||||||
|
Just body -> putStrLn body
|
||||||
|
|
||||||
|
getTweet :: String -> Maybe String
|
||||||
|
getTweet url = do
|
||||||
|
initReq <- parseUrl url
|
||||||
|
let req = initReq { secure = True } -- Turn on https
|
||||||
|
response <- withManager $ httpLbs req
|
||||||
|
body <- responseBody response
|
||||||
|
case body of
|
||||||
|
empty -> return Nothing
|
||||||
|
_ -> return Just (L.unpack body)
|
Loading…
Add table
Add a link
Reference in a new issue