coding utf-8 import logging from optparse import OptionParser import r

 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
# -*- coding: utf-8 -*-
import logging
from optparse import OptionParser
import random
import time
from traceback import format_exc
import re
from seo.awmproxy import get_proxy
from grab.grab import Grab
from seo import whois
from seo.captcha.util import solve_captcha
import settings
from seo.mail import find_message
from seo.html import strip_tags
from common import main, setup_grab, solve_captcha
HOST = 'delicious.com'
def register(email, email_password):
g = setup_grab()
g.setup(url='https://secure.delicious.com/register')
g.repeat(anchor=u'Please start by entering your account')
login = whois.random_login()
password = whois.random_password()
post = {
'user_first': whois.random_en_fname(),
'user_last': whois.random_en_fname(),
'email': email,
'user_name': login,
'password1': password,
'password2': password,
'.secword': None,
'tos': 'on',
'submit': '',
'partner': '',
}
for x in xrange(10):
errors = [strip_tags(unicode(x)) for x in g.soup.findAll('div', 'form_error')]
errors = [x.strip() for x in errors if x.strip()]
if errors:
logging.debug('Found errors: %s' % ', '.join(errors))
if u'username is not available' in g.response_body:
login = whois.random_login()
post['user_name'] = login
if not post['.secword'] or u'Did not match' in g.response_body:
post['.secdata'] = g.input_value('.secdata')
try:
url = 'https://ab.login.yahoo.com/img/%s.jpg' % post['.secdata']
solution = solve_captcha(g, url)
except IOError:
continue
post['.secword'] = solution
g.setup(url='https://secure.delicious.com/register', post=post)
g.request()
if u'account has been successfuly created' in g.response_body:
break
else:
raise Exception('Too many errors')
return (email, login, password)
if __name__ == '__main__':
main(register)