scalpel 0.1.3 → 0.1.3.1
raw patch · 2 files changed
+21/−15 lines, 2 filesdep +scalpeldep −download-curldep ~curldep ~tagsoupPVP ok
version bump matches the API change (PVP)
Dependencies added: scalpel
Dependencies removed: download-curl
Dependency ranges changed: curl, tagsoup
API changes (from Hackage documentation)
Files
scalpel.cabal view
@@ -1,5 +1,5 @@ name: scalpel-version: 0.1.3+version: 0.1.3.1 synopsis: A high level web scraping library for Haskell. description: Scalpel is a web scraping library inspired by libraries like Parsec and@@ -21,7 +21,7 @@ source-repository this type: git location: https://github.com/fimad/scalpel.git- tag: v0.1.3+ tag: v0.1.3.1 library other-extensions:@@ -41,11 +41,10 @@ build-depends: base >= 4.6 && < 5 , bytestring- , curl- , download-curl >= 0.1.4+ , curl >= 1.3.4 , regex-base , regex-tdfa- , tagsoup >= 0.8+ , tagsoup >= 0.12.2 , text default-extensions: OverloadedStrings@@ -56,17 +55,14 @@ test-suite lib-tests type: exitcode-stdio-1.0 main-is: TestMain.hs- hs-source-dirs: src/, tests/+ hs-source-dirs: tests/ build-depends: HUnit , base >= 4.6 && < 5- , bytestring- , curl- , download-curl >= 0.1.4 , regex-base , regex-tdfa- , tagsoup >= 0.8- , text+ , scalpel+ , tagsoup default-extensions: ParallelListComp , PatternGuards
src/Text/HTML/Scalpel/Internal/Scrape/URL.hs view
@@ -9,8 +9,8 @@ import Control.Applicative +import qualified Data.ByteString as BS import qualified Network.Curl as Curl-import qualified Network.Curl.Download as Curl import qualified Text.HTML.TagSoup as TagSoup import qualified Text.StringLike as TagSoup @@ -31,7 +31,17 @@ return (maybeTags >>= scrape scraper) where downloadAsTags url = do- maybeBytes <- maybeRight <$> Curl.openURIWithOpts options url+ maybeBytes <- openURIWithOpts url options return $ (TagSoup.parseTags . TagSoup.castString) <$> maybeBytes- maybeRight (Right a) = Just a- maybeRight _ = Nothing++openURIWithOpts :: URL -> [Curl.CurlOption] -> IO (Maybe BS.ByteString)+openURIWithOpts url opts = do+ resp <- curlGetResponse_ url opts+ return $ if Curl.respCurlCode resp /= Curl.CurlOK+ then Nothing+ else Just $ Curl.respBody resp++curlGetResponse_ :: URL+ -> [Curl.CurlOption]+ -> IO (Curl.CurlResponse_ [(String, String)] BS.ByteString)+curlGetResponse_ = Curl.curlGetResponse_