Created
April 29, 2015 05:59
-
-
Save abhillman/305d3c9a3a337b7708a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Network.HTTP.Conduit (simpleHttp) | |
import qualified Data.ByteString.Lazy as L | |
import qualified Data.ByteString.Lazy.Char8 as C | |
import Text.XML.HXT.Core | |
import Data.List | |
urbanDictionaryURL :: String | |
urbanDictionaryURL = "https://www.urbandictionary.com/random.php" | |
getRandomUrbanEntry :: IO String | |
getRandomUrbanEntry = do | |
html <- simpleHttp urbanDictionaryURL >>= return . C.unpack | |
(runX $ (readString [withParseHTML yes, withWarnings no] html) //> hasAttrValue "class" (isInfixOf "example") >>> getChildren >>> getText) >>= (return . head) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment