Created
August 2, 2012 13:07
-
-
Save aligo/3236935 to your computer and use it in GitHub Desktop.
miao
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from selenium import webdriver | |
from selenium.common.exceptions import NoSuchElementException | |
from selenium.webdriver.common.keys import Keys | |
from tesseract import image_to_string | |
from urllib import urlretrieve | |
import random, time, Image | |
driver = webdriver.Firefox() | |
driver.implicitly_wait(3) | |
i = int(random.random() * 65535 * 65535) | |
while True: | |
i = i + 1 | |
driver.get('http://www.gewara.com/register.xhtml') | |
time.sleep(0.3) | |
driver.find_element_by_id('email').clear() | |
driver.find_element_by_id('email').send_keys('miao' + str(i) + '@miao.com') | |
driver.find_element_by_id('nickname').clear() | |
driver.find_element_by_id('nickname').send_keys('miao' + str(i)) | |
driver.find_element_by_id('password').clear() | |
driver.find_element_by_id('password').send_keys('miaomiao') | |
driver.find_element_by_id('repassword').clear() | |
driver.find_element_by_id('repassword').send_keys('miaomiao') | |
driver.find_element_by_id('captchaInput').clear() | |
driver.find_element_by_id('captchaInput').send_keys('miao') | |
while True: | |
try: | |
captcha_url = driver.find_element_by_id('captchaImg').get_attribute('src') | |
urlretrieve(captcha_url, 'captcha.jpg') | |
captcha = image_to_string(Image.open('captcha.jpg')) | |
captcha = captcha.encode('ascii','ignore') | |
captcha = captcha.replace(' ', '') | |
driver.find_element_by_id('captchaInput').clear() | |
driver.find_element_by_id('captchaInput').send_keys(captcha) | |
except UnicodeDecodeError, e: continue | |
except IOError, e: continue | |
driver.find_element_by_xpath("//form[@id='miForm']/div/label").click() | |
time.sleep(0.3) | |
try: driver.find_element_by_css_selector('#selfalert input').click() | |
except NoSuchElementException, e: break | |
driver.get('http://www.gewara.com/subject/ajax/supportCatPic.xhtml?id=1343197973701XZpAh') | |
time.sleep(0.3) | |
driver.get('http://www.gewara.com/cas/logout.xhtml?ptn=smp') | |
time.sleep(0.3) | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment