packages feed

patronscraper (empty) → 0.0.0.0

raw patch · 4 files changed

+122/−0 lines, 4 filesdep +HandsomeSoupdep +basedep +hxtsetup-changed

Dependencies added: HandsomeSoup, base, hxt

Files

+ LICENSE view
@@ -0,0 +1,22 @@+The MIT License (MIT)++Copyright (c) 2014 Forkk++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ patronscraper.cabal view
@@ -0,0 +1,67 @@+-- ex: set et:+-- The name of the package.+name:                patronscraper++-- The package version.  See the Haskell package versioning policy (PVP) +-- for standards guiding when and how versions should be incremented.+-- http://www.haskell.org/haskellwiki/Package_versioning_policy+-- PVP summary:      +-+------- breaking API changes+--                   | | +----- non-breaking API additions+--                   | | | +--- code changes with no API change+version:             0.0.0.0++-- A short (one-line) description of the package.+synopsis:            A webpage scraper for Patreon which dumps a list of patrons to a text file.++-- A longer description of the package.+-- description:         ++-- The license under which the package is released.+license:             MIT++-- The file containing the license text.+license-file:        LICENSE++-- The package author(s).+author:              Forkk++-- An email address to which users can send suggestions, bug reports, and +-- patches.+maintainer:          forkk@forkk.net++-- A copyright notice.+-- copyright:           ++category:            Web++build-type:          Simple++-- Extra files to be distributed with the package, such as examples or a +-- README.+-- extra-source-files:  ++-- Constraint on the version of Cabal needed to build this package.+cabal-version:       >=1.10+++executable patronscraper+  -- .hs or .lhs file containing the Main module.+  main-is:             Main.hs+  +  -- Modules included in this executable, other than Main.+  -- other-modules:       +  +  -- LANGUAGE extensions used by modules in this package.+  -- other-extensions:    +  +  -- Other library packages from which modules are imported.+  build-depends:      base >=4.6 && <4.7+                    , hxt >=9.3 && <9.4+                    , HandsomeSoup >=0.3 && <0.4+  +  -- Directories containing source files.+  hs-source-dirs:      src+  +  -- Base language which the package is written in.+  default-language:    Haskell2010+  
+ src/Main.hs view
@@ -0,0 +1,31 @@+module Main where++import Control.Arrow+import Control.Applicative+import System.Environment+import Text.XML.HXT.Core+import Text.HandsomeSoup++main :: IO ()+main = do+    page <- getPatreonPage+    patrons <- scrapePatrons page+    mapM_ putStrLn patrons++getPatreonPage :: IO (String)+getPatreonPage = do+    args <- getArgs+    if length args /= 1+       then error "Usage: patronscraper <URL>"+       else return $ head args++scrapePatrons :: String -> IO [String]+scrapePatrons page = do+    patrons <- runX $ fromUrl page+        >>> css ".shareWindow"+        >>> (deep $ hasName "h1")+        >>> (deep $ hasName "a")+        >>> deep isText+        >>> getText+    return patrons+