Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 21c5fa72eb
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (34 sloc) 1.311 kb
module Text.Bibtex.SearchDBLPURIs (
) where
import Network.HTTP hiding (Done)
import Data.RDF
import Data.RDF.TriplesGraph
import Text.RDF.RDF4H.XmlParser
import Data.List.Split
import System.IO (stdout, stderr, hSetBuffering, BufferMode(..))
import qualified Data.Text as T
queryURI :: String -> String
queryURI name = "" ++ urlEncode name
findURIByName :: String -> IO [String]
findURIByName name = do
hSetBuffering stdout LineBuffering
hSetBuffering stderr LineBuffering
let url = queryURI name
request = replaceHeader HdrUserAgent "dblp2bib-client" (getRequest url)
xml <- simpleHTTP request >>= getResponseBody
let doc = elimXmlHeader xml -- hack
let (Right (rdf::TriplesGraph)) = parseXmlRDF Nothing Nothing (T.pack doc)
return $ getURIs rdf
getURIs :: TriplesGraph -> [String]
getURIs rdf =
let triples = query rdf Nothing (Just (unode "link")) Nothing
linksURIs = map objectOf triples
links = map (\(UNode s) -> t2s s) linksURIs
in links
-- This is a hack. This should be resolved by:
elimXmlHeader :: String -> String
elimXmlHeader xml =
let xs = splitOn "\n" xml
in unlines $ tail xs
Jump to Line
Something went wrong with that request. Please try again.