import os from sys import exit from collections import OrderedDict from cStringIO import StringIO from PyQt4.QtCore import QObject, QBuffer, QIODevice from PyQt4.QtGui import QApplication, QWidget, QImage, QVBoxLayout, QHBoxLayout from PyQt4.QtGui import QLabel, QPixmap from opencv.cv import * from opencv.highgui import * from opencv import adaptors from opencv.adaptors import PIL2Ipl from PIL import Image from base import getlog, colorize, RED, GREEN log = getlog('transformer') class TransformError(Exception): pass # преобразование изображений разных форматов друг в друга def QIm2PIL(qimg): buff = QBuffer() buff.open(QIODevice.WriteOnly) qimg.save(buff, 'BMP') fp = StringIO() fp.write(buff.data()) buff.close() fp.seek(0)
# -*- coding: utf-8 -*- import sys import signal from PyQt4.QtCore import QEventLoop, QFileInfo, QFile, QFileInfo, QUrl, QIODevice, QTimer from PyQt4.QtGui import QApplication, QImage from PyQt4.QtWebKit import QWebPage, QWebView from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkDiskCache, QNetworkRequest from settings import JQUERY_PATH, CACHE_PATH from base import getlog, colorize, RED, GREEN log = getlog('browser') # Немного пофиксенный кеш # QNetworkDiskCache не сохраняет данные с флагом saveToDisk=False # Сохраняем все данные, выставляя им saveToDisk=True class Cache(QNetworkDiskCache): def prepare(self, metaData): metaData.setSaveToDisk(True) return QNetworkDiskCache.prepare(self, metaData) # Менеджер с отладкой class Manager(QNetworkAccessManager): def __init__(self, parent=None): QNetworkAccessManager.__init__(self, parent) '''
# -*- coding: utf-8 -*- import sys from opencv.cv import * from PyQt4.QtGui import QApplication from picker import Picker from browser import Browser from transformer import Transformer, TransformError from analyzer import Analyzer from base import getlog, colorize, RED, GREEN, YELLOW from settings import CAPTCHA_PATH, SYMBOLS_PATH log = getlog('smswebmoney') class Implem(Picker): def init(self): self.site = 'smswebmoney' self.symqty = 4 self.symsize = (20, 30) self.charset = '23456789ABCDEFGHIJKMNPRSTUVWXYZ' def collect(self): b = Browser() for i in xrange(200): log.info('LOAD PAGE WITH CAPTCHA') b.get('http://sms-webmoney.ru/') captcha = 'http://sms-webmoney.ru/img.php' b.save(captcha, CAPTCHA_PATH + self.site + '/%02d.png' % i)
# -*- coding: utf-8 -*- from opencv.cv import * from picker import Picker from browser import Browser from transformer import Transformer, TransformError from analyzer import Analyzer from base import getlog, colorize, RED, GREEN, YELLOW log = getlog('wmstream') class Implem(Picker): def picup(self): browser.show() browser.get('http://wmstream.ru/') print 'GET PAGE' browser.sleep(1000) print 'GET CAPTCHA' captcha = browser.js('$("#wmbonus_form_captcha img")[0].src') browser.sleep(1000) t.load('orig', browser.image(captcha)) t.show() browser.save(captcha, '/home/polzuka/inspirado/symbols/first') t.resizeby('resize', t['orig'], 4, 4) t.grayscale('grayscale', t['resize'], 2) t.binarize('binarize', t['grayscale'], 200, CV_THRESH_BINARY)
# -*- coding: utf-8 -*- import os import re from pyfann import libfann from opencv.highgui import cvLoadImage, CV_LOAD_IMAGE_GRAYSCALE from settings import SYMBOL_FILTER, SYMBOLS_PATH, NETS_PATH,TRAINS_PATH from base import getlog, colorize, RED, GREEN log = getlog('anayzer') # Нейронная сеть для распознавния капчи class Analyzer(): # site - имя сайта # picsize - размер картинки, содержащей один символ (x, y) # charset - строка, содержащая все символы, встречающиеся в капче def __init__(self, site, picsize, charset): self.site = site self.trainpath = TRAINS_PATH + self.site + '.trn' self.netpath = NETS_PATH + self.site + '.ann' self.symbolpath = SYMBOLS_PATH + self.site self.charset = charset self.input = picsize[0] * picsize[1] self.output = len(charset) self.hidden = self.input / 3 self.layers = 3
# -*- coding: utf-8 -*- from opencv.cv import * from picker import Picker from browser import Browser from transformer import Transformer, TransformError from analyzer import Analyzer from base import getlog, colorize, RED, GREEN, YELLOW log = getlog('wmtake') class Implem(Picker): def init(self): self.site = 'wmtake' self.symsize = (20, 30) self.symqty = 5 self.charset = '123456789' def runup(self): b = Browser() for i in xrange(100): print i b.get('http://wmtake.ru/m.base/bonus.php') captcha = b.js('$("#scode-pic img")[0].src') b.save(captcha, '/home/polzuka/inspirado/captcha/wmtake/%02d.gif' % i) t = Transformer() t.load('orig', b.image(captcha))
# -*- coding: utf-8 -*- import sys from opencv.cv import * from PyQt4.QtGui import QApplication from picker import Picker from browser import Browser from transformer import Transformer, TransformError from analyzer import Analyzer from base import getlog, colorize, RED, GREEN, YELLOW from settings import CAPTCHA_PATH, SYMBOLS_PATH log = getlog('exchangecity') class Implem(Picker): def init(self): self.site = 'fotocity' self.symqty = 5 self.symsize = (20, 30) self.charset = '123456789' def pickup(self): # создаем браузер, которым будем ходить по wmtake.ru b = Browser() # сщздаем анализатор, которым будем распознавать капчу a = Analyzer('wmtake', self.symsize, self.charset) a.load() b.show()
# -*- coding: utf-8 -*- import sys from opencv.cv import * from PyQt4.QtGui import QApplication from picker import Picker from browser import Browser from transformer import Transformer, TransformError from analyzer import Analyzer from base import getlog, colorize, RED, GREEN, YELLOW from settings import CAPTCHA_PATH, SYMBOLS_PATH log = getlog('exchangecity') class Implem(Picker): def init(self): self.site = 'fotocity' self.symqty = 5 self.symsize = (20, 30) self.charset = '123456789' def pickup(self): # создаем браузер, которым будем ходить по wmtake.ru b = Browser() # сщздаем анализатор, которым будем распознавать капчу a = Analyzer('wmtake', self.symsize, self.charset) a.load()
# -*- coding: utf-8 -*- import os import re from pyfann import libfann from opencv.highgui import cvLoadImage, CV_LOAD_IMAGE_GRAYSCALE from settings import SYMBOL_FILTER, SYMBOLS_PATH, NETS_PATH, TRAINS_PATH from base import getlog, colorize, RED, GREEN log = getlog('anayzer') # Нейронная сеть для распознавния капчи class Analyzer(): # site - имя сайта # picsize - размер картинки, содержащей один символ (x, y) # charset - строка, содержащая все символы, встречающиеся в капче def __init__(self, site, picsize, charset): self.site = site self.trainpath = TRAINS_PATH + self.site + '.trn' self.netpath = NETS_PATH + self.site + '.ann' self.symbolpath = SYMBOLS_PATH + self.site self.charset = charset self.input = picsize[0] * picsize[1] self.output = len(charset) self.hidden = self.input / 3 self.layers = 3 self.desiredError = 0.00006
#! /usr/bin/env python # -*- coding: utf-8 -*- import sys from base import getlog, colorize if __name__ == '__main__': log = getlog('implem') log.info('%s: %s' % (sys.argv[0], sys.argv[1:])) if len(sys.argv) < 3: log.info('implem.py: %s' % 'not enought arguments') sys.exit() site, purse = sys.argv[1:] exec('from charity.%s import Implem' % site) implem = Implem() implem.startpickup(purse) sys.exit(implem.exec_())
# -*- coding: utf-8 -*- import signal from PyQt4.QtCore import QTimer from PyQt4.QtGui import QApplication from PyQt4.QtNetwork import QNetworkProxy from base import newnym, getlog, colorize, RED, GREEN from settings import TOR_HOST, TOR_PORT from browser import Browser log = getlog('picker') class Picker(QApplication): def __init__(self): QApplication.__init__(self, []) # qt из коробки не дружит с Сtrl-С signal.signal(signal.SIGINT, signal.SIG_DFL) self.init() # задание размера изображения, набора символов def init(self): raise NotImplementedError('This method is not implemented') # выкачивание с сайта тонн капчи и разбиение ее на символы def collect(self): raise NotImplementedError('This method is not implemented')
# -*- coding: utf-8 -*- import signal from PyQt4.QtCore import QTimer from PyQt4.QtGui import QApplication from PyQt4.QtNetwork import QNetworkProxy from base import newnym, getlog, colorize, RED, GREEN from settings import TOR_HOST, TOR_PORT from browser import Browser log = getlog('picker') class Picker(QApplication): def __init__(self): QApplication.__init__(self, []) # qt из коробки не дружит с Сtrl-С signal.signal(signal.SIGINT, signal.SIG_DFL) self.init() # задание размера изображения, набора символов def init(self): raise NotImplementedError('This method is not implemented') # выкачивание с сайта тонн капчи и разбиение ее на символы def collect(self): raise NotImplementedError('This method is not implemented') # создание и обучение нейронной сети на основе выкачанных капч def analyze(self): raise NotImplementedError('This method is not implemented')