source: trollforge/users/sam/libtroll/lol-amazon.py @ 606

Revision 606, 1.6 KB checked in by literalka, 17 months ago (diff)

done..?

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2
3import re, time, thread, sys, random, libtroll, libimdb, libaccount
4
5id = [ '', '', '']
6while id[1] == '':
7    id = libaccount.make_id(random.randint(0,100000), 4)
8email = id[0].lower() + '@' + id[1]
9print email
10
11troll = libtroll.make_troll()
12#troll.set_verbose(True)
13
14troll.get_url('http://www.chud.com/forums/showthread.php?t=92289')
15
16troll.get_url('http://www.amazon.com/exec/obidos/tg/browse/-/165670011/002-1511680-0932008')
17time.sleep(5)
18
19#ret = troll.get_url('http://www.amazon.com/exec/obidos/tg/browse/-/165673011/ref=amb_left-3_182948401_3/002-1511680-0932008')
20ret = troll.get_url('http://www.amazon.com/exec/obidos/tg/browse/-/169523011/ref=br_bx_c_1_0/002-1511680-0932008')
21time.sleep(10)
22
23reg = re.compile('.*"([^"]*notification-item-request-done[^"]*)".*')
24for l in ret.split('\n'):
25    m = reg.match(l)
26    if m:
27        zob = m.group(1)
28
29data = {}
30data['email'] = email
31reg = re.compile('.*name="(asin[0-9]*)" value=([^ ]*) size.*')
32for l in ret.split('\n'):
33    m = reg.match(l)
34    if m and (random.randint(0,100) < 10):
35        data[m.group(1)] = m.group(2)
36if random.randint(0,100) < 70:
37    data['asin6'] = 'B00005JP4J' # Band of Angels
38if random.randint(0,100) < 70:
39    data['asin28'] = 'B00005JP4T' # There Was a Crooked Man...
40data['max-asin-number'] = '100'
41data['primary-asin'] = ''
42data['show-thank-you-message'] = 'true'
43data['store-name'] = 'dvd'
44troll.set_postdata(data)
45ret = troll.get_url('http://www.amazon.com' + zob)
46
47reg = re.compile('^([^<>]+)<br>$')
48for l in ret.split('\n'):
49    m = reg.match(l)
50    if m:
51        print m.group(1)
52
Note: See TracBrowser for help on using the repository browser.