Attribute error, Cookies not found!

Reply

Join Date: Jul 2008
Posts: 5
Reputation: john_bboy7 is an unknown quantity at this point 
Solved Threads: 0
john_bboy7 john_bboy7 is offline Offline
Newbie Poster

Attribute error, Cookies not found!

 
0
  #1
Jul 25th, 2008
I am getting an attribute error...Group not found on cookie = m.group(1)

Can any one fix my code here?

  1. #!usr/bin/python
  2.  
  3. import re
  4. import urllib
  5. import urllib2
  6.  
  7. def MassVote(first_number, last_number, email1, email3, password, community_id, join = False, unjoin = False):
  8. def curl(url, cookie = None, get_header = False, fields = None):
  9. print url
  10. req = urllib2.Request(url)
  11. if cookie:
  12. req.add_header('Set-Cookie', cookie)
  13. if fields:
  14. req.set_data(fields)
  15. r = urllib2.urlopen(req)
  16. if get_header:
  17. c = str(r.info())
  18. else:
  19. c = r.read()
  20. return c
  21.  
  22. o = 'http://www.orkut.com/'
  23. g = "https://www.google.com/accounts/ClientLogin?Email="
  24.  
  25. for n in range(first_number, last_number+1):
  26.  
  27. l = email1
  28. z = email3
  29. p = password
  30. mail = email1+str(n)+email3
  31.  
  32. r = curl(g+mail+"&Passwd=hellyeah&skipvpage=true&service=orkut")
  33. m = re.search("Auth=(.*)",r,re.I)
  34. auth = m.group(1)
  35.  
  36. r = curl(o+"RedirLogin.aspx?auth=auth", get_header = True)
  37. m = re.match('orkut_state=ORKUTPREF.*',r,re.I)
  38. cookie = m.group(0)
  39.  
  40. r = curl(o+"scrapbook.aspx", cookie)
  41. m = re.findall("value\=\"([^\"]{28,32})\"",r,re.I)
  42. postsig = "POST_TOKEN="+m[0].group(1)+"&signature="+urllib.quote_plus(m[1].group(1))
  43.  
  44. if join:
  45. jin = "http://www.orkut.com/CommunityJoin.aspx?community_id="+community_id
  46. PTSG = postsig+"&Action.join"
  47. r = curl(jin,cookie,True,PTSG)
  48.  
  49. print "Community joined by <b>"+email+"</b><br>"
  50.  
  51. if unjoin:
  52. unjin = "http://www.orkut.com/CommunityUnjoin.aspx?community_id="+community_id
  53. PTSG = postsig+"&Action.unjoin"
  54. r = curl(unjin,cookie,True,PTSG)
  55.  
  56. print "Community unjoined by <b>"+email+"</b><br>"
  57.  
  58. def test():
  59. MassVote(1, 5, 'gamesan', '@yahoo.com', 'hellyeah', '48783497', True, False)
  60.  
  61. if __name__=='__main__':
  62. test()
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,046
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 264
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: Attribute error, Cookies not found!

 
0
  #2
Jul 25th, 2008
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:
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 5
Reputation: john_bboy7 is an unknown quantity at this point 
Solved Threads: 0
john_bboy7 john_bboy7 is offline Offline
Newbie Poster

Re: Attribute error, Cookies not found!

 
0
  #3
Jul 25th, 2008
I translated my php code to python.. my php code is working here:

  1. $r = curl($g.$email1.$n.$email3."&Passwd=$p&skipvpage=true&service=orkut",1,0,0,null);
  2. preg_match_all("/Auth=(.*)/i",$r,$r);
  3. $auth=$r[1][0];
  4.  
  5. $r = curl($o."RedirLogin.aspx?auth=$auth",1,0,1,null);
  6. preg_match_all("/orkut_state=ORKUTPREF.*/i",$r,$r);
  7. $cookie=$r[0][0];

Can anyone translate it right?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,046
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 264
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: Attribute error, Cookies not found!

 
0
  #4
Jul 25th, 2008
Originally Posted by john_bboy7 View Post
$r = curl($o."RedirLogin.aspx?auth=$auth",1,0,1,null);
Right here. In your python script you have 'auth=auth'.

It should be r = curl(o+"RedirLogin.aspx?auth=%s" % auth, get_header = True)
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 5
Reputation: john_bboy7 is an unknown quantity at this point 
Solved Threads: 0
john_bboy7 john_bboy7 is offline Offline
Newbie Poster

Re: Attribute error, Cookies not found!

 
0
  #5
Jul 25th, 2008
Originally Posted by jlm699 View Post
Right here. In your python script you have 'auth=auth'.

It should be r = curl(o+"RedirLogin.aspx?auth=%s" % auth, get_header = True)
Yes it worked but i am still getting that error:

cookie = m.group(0)
AttributeError: 'NoneType' object has no attribute 'group'
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,046
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 264
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: Attribute error, Cookies not found!

 
0
  #6
Jul 25th, 2008
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.
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 5
Reputation: john_bboy7 is an unknown quantity at this point 
Solved Threads: 0
john_bboy7 john_bboy7 is offline Offline
Newbie Poster

Re: Attribute error, Cookies not found!

 
0
  #7
Jul 25th, 2008
Originally Posted by jlm699 View Post
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.
Yes you are right at ur place. But i think that is needed to store cookies... And i m translating this from php.. how come orkut_state= is there and is working... So thats y i put this orkut_state= in python too.. i will show u my entire php code.. u might get some idea..

PHP code:
  1. <?php
  2. function MassVote() {
  3. function curl($a,$b,$c,$d,$e){
  4. $ch = curl_init();
  5. curl_setopt_array($ch,
  6. array(
  7. CURLOPT_URL => $a,
  8. CURLOPT_RETURNTRANSFER => $b,
  9. CURLOPT_COOKIE => $c,
  10. CURLOPT_HEADER => $d,
  11. CURLOPT_NOBODY => $d,
  12. CURLOPT_CUSTOMREQUEST => ($e)?"POST":"GET",
  13. CURLOPT_POSTFIELDS => $e
  14. )
  15. );
  16. $g = curl_exec($ch);
  17. curl_close($ch);
  18. return $g;
  19. }
  20.  
  21. $number = range($_POST['nf'],$_POST['nl']);
  22.  
  23. $email1 = $_POST['email1'];
  24. $email3 = $_POST['email3'];
  25.  
  26. $senha = $_POST['senha'];
  27.  
  28. $o = "http://www.orkut.com/";
  29. $g = "https://www.google.com/accounts/ClientLogin?Email=";
  30. $cmm = $_POST['cmm'];
  31.  
  32.  
  33. for($i=0;$i<count($number);$i++){
  34.  
  35. $n = $number[$i];
  36.  
  37. $l = $email1;
  38. $z = $email3;
  39. $p = $senha;
  40.  
  41. $r = curl($g.$email1.$n.$email3."&Passwd=$p&skipvpage=true&service=orkut",1,0,0,null);
  42. preg_match_all("/Auth=(.*)/i",$r,$r);
  43. $auth=$r[1][0];
  44.  
  45. $r = curl($o."RedirLogin.aspx?auth=$auth",1,0,1,null);
  46. preg_match_all("/orkut_state=ORKUTPREF.*/i",$r,$r);
  47. $cookie=$r[0][0];
  48.  
  49. $r = curl($o."scrapbook.aspx",1,$cookie,0,null);
  50. preg_match_all("/value\=\"([^\"]{28,32})\"/i",$r,$r);
  51. $postsig= "POST_TOKEN=".$r[1][0]."&signature=".rawurlencode($r[1][1]);
  52.  
  53. $sscrap = "http://www.orkut.com/Scrapbook.aspx?uid=12479430764362367628";
  54. $r = curl($sscrap,1,$cookie,1,$postsig."&scrapText=[b]Zeroburn rox! [:P] using Sb flooder&Action.submit=1");
  55.  
  56. $jin = "http://www.orkut.com/CommunityJoin.aspx?cmm=".$cmm;
  57. $PTSG = $postsig."&Action.join";
  58. $r = curl($jin,1,$cookie,1,$PTSG);
  59.  
  60. print_r("Community joined by <b>".$email1.$n.$email3."</b><br>");
  61.  
  62.  
  63.  
  64. flush();
  65.  
  66. };
  67. }
  68. if(isset($_POST['cmm'])){
  69. MassVote();
  70. }
  71. ?>

I hope u have got some idea.. that it needs cookies to go to any page...
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,046
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 264
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: Attribute error, Cookies not found!

 
0
  #8
Jul 25th, 2008
I would imagine that the problem is with the python version of curl that you wrote. Perhaps you should try looking into PycURL.
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 5
Reputation: john_bboy7 is an unknown quantity at this point 
Solved Threads: 0
john_bboy7 john_bboy7 is offline Offline
Newbie Poster

Re: Attribute error, Cookies not found!

 
0
  #9
Jul 29th, 2008
Originally Posted by jlm699 View Post
I would imagine that the problem is with the python version of curl that you wrote. Perhaps you should try looking into PycURL.
Well thanks for helping.

One more thing. Now i have the cookies.

  1. cookies = "somecookies"
  2. 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.

  1. 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..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC