| | |
Attribute error, Cookies not found!
![]() |
•
•
Join Date: Jul 2008
Posts: 5
Reputation:
Solved Threads: 0
I am getting an attribute error...Group not found on cookie = m.group(1)
Can any one fix my code here?
Can any one fix my code here?
Python Syntax (Toggle Plain Text)
#!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()
If your regex doesn't match anything it returns a None, which gets stored to m. You should have a check before accessing m.groups by saying
if m: •
•
Join Date: Jul 2008
Posts: 5
Reputation:
Solved Threads: 0
I translated my php code to python.. my php code is working here:
Can anyone translate it right?
Python Syntax (Toggle Plain Text)
$r = curl($g.$email1.$n.$email3."&Passwd=$p&skipvpage=true&service=orkut",1,0,0,null); preg_match_all("/Auth=(.*)/i",$r,$r); $auth=$r[1][0]; $r = curl($o."RedirLogin.aspx?auth=$auth",1,0,1,null); preg_match_all("/orkut_state=ORKUTPREF.*/i",$r,$r); $cookie=$r[0][0];
Can anyone translate it right?
That is because like I said: if the regex doesn't match anything it returns a None. Try checking your code line by line in an interpreter to see what's happening I got to the line that says
r = curl(o+'RedirLogin.aspx?auth=%s' % auth, get_header=True) . When you check the value of 'r' you see that there is no orkut_state= anything. •
•
Join Date: Jul 2008
Posts: 5
Reputation:
Solved Threads: 0
•
•
•
•
That is because like I said: if the regex doesn't match anything it returns a None. Try checking your code line by line in an interpreter to see what's happening I got to the line that says r = curl(o+'RedirLogin.aspx?auth=%s' % auth, get_header=True) . When you check the value of 'r' you see that there is no orkut_state= anything. PHP code:
Python Syntax (Toggle Plain Text)
<?php function MassVote() { function curl($a,$b,$c,$d,$e){ $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => $a, CURLOPT_RETURNTRANSFER => $b, CURLOPT_COOKIE => $c, CURLOPT_HEADER => $d, CURLOPT_NOBODY => $d, CURLOPT_CUSTOMREQUEST => ($e)?"POST":"GET", CURLOPT_POSTFIELDS => $e ) ); $g = curl_exec($ch); curl_close($ch); return $g; } $number = range($_POST['nf'],$_POST['nl']); $email1 = $_POST['email1']; $email3 = $_POST['email3']; $senha = $_POST['senha']; $o = "http://www.orkut.com/"; $g = "https://www.google.com/accounts/ClientLogin?Email="; $cmm = $_POST['cmm']; for($i=0;$i<count($number);$i++){ $n = $number[$i]; $l = $email1; $z = $email3; $p = $senha; $r = curl($g.$email1.$n.$email3."&Passwd=$p&skipvpage=true&service=orkut",1,0,0,null); preg_match_all("/Auth=(.*)/i",$r,$r); $auth=$r[1][0]; $r = curl($o."RedirLogin.aspx?auth=$auth",1,0,1,null); preg_match_all("/orkut_state=ORKUTPREF.*/i",$r,$r); $cookie=$r[0][0]; $r = curl($o."scrapbook.aspx",1,$cookie,0,null); preg_match_all("/value\=\"([^\"]{28,32})\"/i",$r,$r); $postsig= "POST_TOKEN=".$r[1][0]."&signature=".rawurlencode($r[1][1]); $sscrap = "http://www.orkut.com/Scrapbook.aspx?uid=12479430764362367628"; $r = curl($sscrap,1,$cookie,1,$postsig."&scrapText=[b]Zeroburn rox! [:P] using Sb flooder&Action.submit=1"); $jin = "http://www.orkut.com/CommunityJoin.aspx?cmm=".$cmm; $PTSG = $postsig."&Action.join"; $r = curl($jin,1,$cookie,1,$PTSG); print_r("Community joined by <b>".$email1.$n.$email3."</b><br>"); flush(); }; } if(isset($_POST['cmm'])){ MassVote(); } ?>
I hope u have got some idea.. that it needs cookies to go to any page...
I would imagine that the problem is with the python version of curl that you wrote. Perhaps you should try looking into PycURL.
•
•
Join Date: Jul 2008
Posts: 5
Reputation:
Solved Threads: 0
•
•
•
•
I would imagine that the problem is with the python version of curl that you wrote. Perhaps you should try looking into PycURL.
One more thing. Now i have the cookies.
Python Syntax (Toggle Plain Text)
cookies = "somecookies" r = curl("http://www.orkut.com/Scrapbook.aspx", cookie)
We need to login before we can view this page...http://www.orkut.com/Scrapbook.aspx
So i m adding variable at the end of this line.
Python Syntax (Toggle Plain Text)
r = curl("http://www.orkut.com/Scrapbook.aspx", cookie)
But it doesn't gets logged in. it simply shows the login page.. Can u tell me how to log in.. after i m having cookies..
![]() |
Similar Threads
- Think I'm Clean Now. Can anyone verify my Hijack Log? (Viruses, Spyware and other Nasties)
Other Threads in the Python Forum
- Previous Thread: python programa question
- Next Thread: Pythagorean Theorem Calculator
| Thread Tools | Search this Thread |
advanced aliased bash beginner bits calling casino changecolor clear command convert corners count csv cturtle cursor def definedlines dictionary digital dynamic dynamically event events examples external file float format frange function google gui hints homework i/o iframe import info input jaunty java line linux list lists loop matching mouse multiple number numbers obexftp output parsing path port prime programming projects py py2exe pygame pygtk python random rational raw_input recursion return scrolledtext signal singleton skinning stderr string strings subprocess table tails terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode urllib urllib2 valueerror variable voip web-scrape whileloop word wxpython






