-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Interface for antigate.com captcha recognition API -- -- Haskell interface for antigate.com captcha recognition service and -- other services supporting its API (e.g. captchabot, decaptcher) @package antigate @version 2.0.2 -- | Example: -- --
-- {-# LANGUAGE OverloadedStrings #-}
-- import Text.Recognition.Antigate
-- import Data.Default
-- import Network
-- import Control.Monad
-- import Control.Monad.IO.Class
-- import Data.ByteString.Lazy hiding (putStrLn)
-- import System.Timeout
--
-- myApiKey :: ApiKey
-- myApiKey = "0123456789abcdef0123456789abcdef"{api_host="antigate.com"}
--
-- downloadJpegCaptcha :: Manager -> IO ByteString
-- downloadJpegCaptcha = undefined
--
-- answerCaptcha :: String -> Manager -> IO Bool
-- answerCaptcha = undefined
--
-- main :: IO ()
-- main = withSocketsDo $ do
-- res <- timeout (30*1000000) $ withManager $ \m -> do
-- bytes <- liftIO $ downloadJpegCaptcha m
-- (id, answer) <- solveCaptcha def myApiKey def{phrase=True} "captcha.jpg" bytes m
-- res <- liftIO $ answerCaptcha answer m
-- unless res $ reportBad myApiKey id m
-- return res
-- case res of
-- Nothing -> do
-- putStrLn "Timed out"
-- Just True -> do
-- putStrLn "Solved successfully"
-- Just False -> do
-- putStrLn "Couldn't solve"
--
module Text.Recognition.Antigate
-- | Antigate API access key paired with service provider's host. At least
-- these services claim to support Antigate API: Antigate, Captchabot,
-- Decaptcher, ExpertDecoders, ImageTyperz, DeathByCaptcha and Pixodrom.
data ApiKey
-- | This is a record selector
api_key :: ApiKey -> String
-- | default: "antigate.com". This is a record selector
api_host :: ApiKey -> String
type CaptchaID = Int
-- | Properties of the captcha to be solved. See
-- http://antigate.com/panel.php?action=api
data CaptchaConf
CaptchaConf :: Bool -> Bool -> Maybe Bool -> Bool -> Word -> Word -> Bool -> Maybe Double -> CaptchaConf
-- |
[phrase] :: CaptchaConf -> Bool
-- |
[regsense] :: CaptchaConf -> Bool
-- | -- api_counter = \phase count -> do -- if count == 0 -- then putStrLn $ show phase ++ " began" -- else putStrLn $ show phase ++ " retries: " ++ show count ---- -- Default: _ _ -> return () [api_counter] :: SolveConf -> Phase -> Int -> IO () -- | This will be called when upload phase finishes [api_upload_callback] :: SolveConf -> CaptchaID -> IO () data Phase UploadPhase :: Phase CheckPhase :: Phase -- | High level function to solve captcha, blocks until answer is provided -- (about 2-10 seconds). -- -- throws SolveException or HttpException when something -- goes wrong. solveCaptcha :: (Failure HttpException m, MonadIO m, MonadThrow m) => SolveConf -> ApiKey -> CaptchaConf -> FilePath -> ByteString -> Manager -> m (CaptchaID, String) solveCaptchaFromFile :: (Failure HttpException m, MonadIO m, MonadThrow m) => SolveConf -> ApiKey -> CaptchaConf -> FilePath -> Manager -> m (CaptchaID, String) -- | upload captcha for recognition -- -- throws HttpException on network errors. uploadCaptcha :: (Failure HttpException m, MonadIO m, MonadThrow m) => ApiKey -> CaptchaConf -> FilePath -> ByteString -> Manager -> m (ApiResult CaptchaID) uploadCaptchaFromFile :: (Failure HttpException m, MonadIO m, MonadThrow m) => ApiKey -> CaptchaConf -> FilePath -> Manager -> m (ApiResult CaptchaID) -- | retrieve captcha status -- -- throws HttpException on network errors. checkCaptcha :: (Failure HttpException m, MonadIO m, MonadThrow m) => ApiKey -> CaptchaID -> Manager -> m (ApiResult String) -- | retrieve multiple captcha status -- -- throws HttpException on network errors. checkCaptchas :: (Failure HttpException m, MonadIO m, MonadThrow m) => ApiKey -> [CaptchaID] -> Manager -> m [ApiResult String] -- | report bad captcha result -- -- throws HttpException on network errors. reportBad :: (Failure HttpException m, MonadIO m, MonadThrow m) => ApiKey -> CaptchaID -> Manager -> m Bool -- | retrieve your current account balance -- -- throws HttpException on network errors. getBalance :: (Failure HttpException m, MonadIO m, MonadThrow m) => ApiKey -> Manager -> m Double -- | Keeps track of open connections for keep-alive. -- -- If possible, you should share a single Manager between multiple -- threads and requests. -- -- Since 0.1.0 data Manager :: * -- | Create a Manager. The Manager will be shut down -- automatically via garbage collection. -- -- Creating a new Manager is a relatively expensive operation, you -- are advised to share a single Manager between requests instead. -- -- The first argument to this function is often -- defaultManagerSettings, though add-on libraries may provide a -- recommended replacement. -- -- Since 0.1.0 newManager :: ManagerSettings -> IO Manager -- | Close all connections in a Manager. -- -- Note that this doesn't affect currently in-flight connections, meaning -- you can safely use it without hurting any queries you may have -- concurrently running. -- -- Since 0.1.0 closeManager :: Manager -> IO () withManager :: (MonadIO m, MonadBaseControl IO m) => (Manager -> ResourceT m a) -> m a -- | Parse antigate's upload response parseUploadResponse :: String -> ApiResult CaptchaID -- | Parse antigate's check response parseCheckResponse :: String -> ApiResult String -- | Parse antigate's multi-check response parseMultiCheckResponse :: String -> ApiResult String -- | Parse antigate's multi-check response parseMultiCheckResponses :: String -> [ApiResult String] -- | Marshal ApiResult back to its text form renderApiResult :: ApiResult String -> String instance GHC.Enum.Bounded Text.Recognition.Antigate.Phase instance GHC.Enum.Enum Text.Recognition.Antigate.Phase instance GHC.Classes.Ord Text.Recognition.Antigate.Phase instance GHC.Classes.Eq Text.Recognition.Antigate.Phase instance GHC.Read.Read Text.Recognition.Antigate.Phase instance GHC.Show.Show Text.Recognition.Antigate.Phase instance GHC.Show.Show Text.Recognition.Antigate.SolveException instance GHC.Base.Functor Text.Recognition.Antigate.ApiResult instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.Recognition.Antigate.ApiResult a) instance GHC.Read.Read a => GHC.Read.Read (Text.Recognition.Antigate.ApiResult a) instance GHC.Show.Show a => GHC.Show.Show (Text.Recognition.Antigate.ApiResult a) instance GHC.Read.Read Text.Recognition.Antigate.CaptchaConf instance GHC.Show.Show Text.Recognition.Antigate.CaptchaConf instance GHC.Read.Read Text.Recognition.Antigate.ApiKey instance GHC.Show.Show Text.Recognition.Antigate.ApiKey instance GHC.Classes.Ord Text.Recognition.Antigate.ApiKey instance GHC.Classes.Eq Text.Recognition.Antigate.ApiKey instance Data.Default.Class.Default Text.Recognition.Antigate.ApiKey instance Data.String.IsString Text.Recognition.Antigate.ApiKey instance Control.DeepSeq.NFData Text.Recognition.Antigate.ApiKey instance Data.Default.Class.Default Text.Recognition.Antigate.CaptchaConf instance Control.DeepSeq.NFData Text.Recognition.Antigate.CaptchaConf instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Text.Recognition.Antigate.ApiResult a) instance GHC.Exception.Exception Text.Recognition.Antigate.SolveException instance Control.DeepSeq.NFData Text.Recognition.Antigate.SolveException instance Control.DeepSeq.NFData Text.Recognition.Antigate.Phase instance Data.Default.Class.Default Text.Recognition.Antigate.SolveConf instance GHC.Show.Show Text.Recognition.Antigate.SolveConf instance Control.DeepSeq.NFData Text.Recognition.Antigate.SolveConf