The dom-selector package

[Tags: bsd3, library]

CSS selector support for xml-conduit/html-conduit. This package supports compile-time checking of CSS selectors using quasiquotes. All DOM traversals are purely functional.

 -- The following pragmas should be put first (Haddock does not accept a pragma notation.)
 -- LANGUAGE OverloadedStrings, QuasiQuotes

 module Main (main) where

 import Text.XML.Cursor (fromDocument)
 import Text.HTML.DOM (parseLBS)
 import qualified Data.Text.Lazy.IO as TI (putStrLn)

 import Control.Monad (mapM_)

 import Text.XML.Scraping (innerHtml)
 import Text.XML.Selector.TH

 import Network.HTTP.Conduit
 import Data.Conduit.Binary

 main :: IO ()
 main = do
    root <- fmap (fromDocument . parseLBS) $ simpleHttp "https://news.google.com/"
    let cs = queryT [jq| h2 span.titletext |] root
    mapM_ (TI.putStrLn . innerHtml) cs

You can use some elementary CSS selectors for traversing a DOM tree.

https://github.com/nebuta/dom-selector/tree/master/examples

Changes:

Ver 0.2.1: Inappropriate Safe Haskell pragma was removed.

Ver 0.2: All scraping functions in Text.XML.Scraping return lazy text now. They are implemented with a type class.


Properties

Versions0.1.0.0, 0.2.0.0, 0.2.0.1
Dependenciesbase (>=4.0 && <5), blaze-html (>=0.5), containers (>=0.4), html-conduit (>=0.1), parsec (>=3.1), QuickCheck (>=2.4), template-haskell (>=2.5), text (>=0.11), th-lift (>=0.5), xml-conduit
LicenseBSD3
CopyrightCopyright 2012-2013 by Nebuta Lab
AuthorNebuta Lab
Maintainernebuta.office@gmail.com
Stabilitybeta
CategoryWeb
Home pagehttps://github.com/nebuta/
Source repositoryhead: git clone https://github.com/nebuta/dom-selector
Upload dateMon Jun 17 00:07:38 UTC 2013
Uploaded bynebuta
DistributionsNixOS:0.2.0.1
Downloads544 total (55 in last 30 days)

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees