I am getting an attribute error...Group not found on cookie = m.group(1)
Can any one fix my code here?
#!usr/bin/python
import re
import urllib
import urllib2
def MassVote(first_number, last_number, email1, email3, password, community_id, join = False, unjoin = False):
def curl(url, cookie = None, get_header = False, fields = None):
print url
req = urllib2.Request(url)
if cookie:
req.add_header('Set-Cookie', cookie)
if fields:
req.set_data(fields)
r = urllib2.urlopen(req)
if get_header:
c = str(r.info())
else:
c = r.read()
return c
o = 'http://www.orkut.com/'
g = "https://www.google.com/accounts/ClientLogin?Email="
for n in range(first_number, last_number+1):
l = email1
z = email3
p = password
mail = email1+str(n)+email3
r = curl(g+mail+"&Passwd=hellyeah&skipvpage=true&service=orkut")
m = re.search("Auth=(.*)",r,re.I)
auth = m.group(1)
r = curl(o+"RedirLogin.aspx?auth=auth", get_header = True)
m = re.match('orkut_state=ORKUTPREF.*',r,re.I)
cookie = m.group(0)
r = curl(o+"scrapbook.aspx", cookie)
m = re.findall("value\=\"([^\"]{28,32})\"",r,re.I)
postsig = "POST_TOKEN="+m[0].group(1)+"&signature="+urllib.quote_plus(m[1].group(1))
if join:
jin = "http://www.orkut.com/CommunityJoin.aspx?community_id="+community_id
PTSG = postsig+"&Action.join"
r = curl(jin,cookie,True,PTSG)
print "Community joined by <b>"+email+"</b><br>"
if unjoin:
unjin = "http://www.orkut.com/CommunityUnjoin.aspx?community_id="+community_id
PTSG = postsig+"&Action.unjoin"
r = curl(unjin,cookie,True,PTSG)
print "Community unjoined by <b>"+email+"</b><br>"
def test():
MassVote(1, 5, 'gamesan', '@yahoo.com', 'hellyeah', '48783497', True, False)
if __name__=='__main__':
test()