-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhs-scrape.cabal
112 lines (107 loc) · 3.66 KB
/
hs-scrape.cabal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.33.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: 0331bc414b26cd9966e36cf4be33e86e2f0e535f42ce38e93283bfa88e6b2b99
name: hs-scrape
version: 0.1.0.1
synopsis: Simple and easy web scraping and automation in Haskell.
description: Shpider/mechanize inspired web automation with a focus on convenience for web scraping.
.
A fully functional example of logging into paypal and getting your account balance (<https://github.com/codygman/hs-scrape-paypal-login cabal buildable repo of this example>):
.
> import Control.Applicative
> import Control.Monad
> import Control.Monad.IO.Class
> import Data.Maybe
> import Data.Monoid
> import qualified Data.Text as T
> import Data.Text.IO (putStrLn)
> import Network.Scraper.State
> import Prelude hiding (putStrLn)
> import Text.XML.Cursor (attributeIs, content, element, ($//),
> (&/))
>
> getPaypalBalance cursor = fromMaybe (error "Failed to get balance") $ listToMaybe $
> cursor $//
> element "div" >=> attributeIs "class" "balanceNumeral" &/
> element "span" >=> attributeIs "class" "h2" &/
> content
>
> main = do
> runScraper $ do
> get "https://www.paypal.com/login"
>
> postToForm (Name "login_form") (Just creds) AllVisible
>
> get "https://www.paypal.com/myaccount/home"
>
> cursor <- liftM (fromMaybe (error "Couldn't get cursor")) getCurrentCursor
> liftIO . putStrLn $ "Your Paypal balance is: " <> getPaypalBalance cursor
>
> where creds = [ ("login_email", "[email protected]") -- put your credentials here
> , ("login_password", "password")]
.
category: Web
homepage: https://github.com/httpscodygman/hs-scrape#readme
bug-reports: https://github.com/httpscodygman/hs-scrape/issues
author: Cody Goodman
maintainer: [email protected]
license: MIT
license-file: LICENSE
build-type: Simple
source-repository head
type: git
location: https://github.com/httpscodygman/hs-scrape
library
exposed-modules:
Network.Scraper.State
other-modules:
Paths_hs_scrape
hs-source-dirs:
src
build-depends:
base >=4.7 && <5
, bytestring
, containers
, data-default
, exceptions
, hspec
, html-conduit
, lens
, retry
, safe
, text
, transformers
, url
, wreq
, xml-conduit
default-language: Haskell2010
test-suite hs-scrape-test
type: exitcode-stdio-1.0
main-is: Tests.hs
other-modules:
Paths_hs_scrape
hs-source-dirs:
tests
build-depends:
base
, bytestring
, containers
, data-default
, exceptions
, hs-scrape
, hspec
, html-conduit
, lens
, retry
, safe
, tasty
, tasty-hunit
, text
, transformers
, url
, wreq
, xml-conduit
default-language: Haskell2010