When the script encounters a CAPTCHA code the module returns the URL so you can retrieve the image and enter the code to continue. After several hours of tweaking my script I decided to use Ethereal to capture the packets from both a manual submission and my script. See below:
# MANUAL SUBMISSION Hypertext Transfer Protocol GET /CAPTCHA/CAPTCHA.aspx?SecurityToken=8C75EEB0D4964AE99A9786283B +AE95BA HTTP/1.1\r\n Request Method: GET Request URI: /CAPTCHA/CAPTCHA.aspx?SecurityToken=8C75EEB0D4964 +AE99A9786283BAE95BA Request Version: HTTP/1.1 Accept: */*\r\n Referer: http://collect.myspace.com/index.cfm?fuseaction=invite.ad +dfriend_verify&friendID=107828070\r\n Accept-Language: en-us\r\n Accept-Encoding: gzip, deflate\r\n User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1 +; .NET CLR 1.1.4322; .NET CLR 2.0.50727)\r\n Host: security.myspace.com\r\n Connection: Keep-Alive\r\n Cookie: NGUserID=a28255d-528-1162008931-2; AUTOSONGPLAY=0; MYSPACE +=myspace; DERDB=ZG9tYWluPW1ldHJvY2FzdCZ0bGQ9bmV0JnNtb2tlcj0wJnNleHByZ +WY9MSZ1dHlwZT0yJnJlbGlnaW9uaWQ9MCZyZWdpb249JnBvc3RhbGNvZGU9Mzg2OCZtYX +JpdGFsc3RhdHVzPU0maW5jb21laWQ9MCZoZ \r\n Hypertext Transfer Protocol POST /index.cfm?fuseaction=invite.addFriendsProcess&Mytoken=D40C54 +80-735E-4478-87F5593FAE9DF7CB7111271 HTTP/1.1\r\n Request Method: POST Request URI: /index.cfm?fuseaction=invite.addFriendsProcess&My +token=D40C5480-735E-4478-87F5593FAE9DF7CB7111271 Request Version: HTTP/1.1 Accept: */*\r\n Referer: http://collect.myspace.com/index.cfm?fuseaction=invite.ad +dfriend_verify&friendID=107828070\r\n Accept-Language: en-us\r\n Content-Type: application/x-www-form-urlencoded\r\n Accept-Encoding: gzip, deflate\r\n User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1 +; .NET CLR 1.1.4322; .NET CLR 2.0.50727)\r\n Host: collect.myspace.com\r\n Content-Length: 255\r\n Connection: Keep-Alive\r\n Cache-Control: no-cache\r\n Cookie: NGUserID=a28255d-528-1162008931-2; AUTOSONGPLAY=0; MYSPACE +=myspace; DERDB=ZG9tYWluPW1ldHJvY2FzdCZ0bGQ9bmV0JnNtb2tlcj0wJnNleHByZ +WY9MSZ1dHlwZT0yJnJlbGlnaW9uaWQ9MCZyZWdpb249JnBvc3RhbGNvZGU9Mzg2OCZtYX +JpdGFsc3RhdHVzPU0maW5jb21laWQ9MCZoZ \r\n Line-based text data: application/x-www-form-urlencoded hashcode=MIGLBgorBgEEAYI3WAOkoH0wewYKKwYBBAGCN1gDAaBtMGsCAwIAAQICZ +gMCAgDABAiDFtagrDKBJQQQAZ1eoDG30LD3hChb1lyNxwRAYC67osSYAgTw2Azeh2qaiI +5qT%2BxhhFRaGMIEnmUNMa1p8cLj%2BS6AZrPW4znnqoecL5fvN3NKkpPP1tB%2BpmtKe +g%3D%3D&friendID=107828070&CAPTCHAR # SCRIPT SUBMISSION Hypertext Transfer Protocol GET /CAPTCHA/CAPTCHA.aspx?SecurityToken=3E4F1A84164B4DE2BFEAE76376 +0BEB32 HTTP/1.0\r\n Request Method: GET Request URI: /CAPTCHA/CAPTCHA.aspx?SecurityToken=3E4F1A84164B4 +DE2BFEAE763760BEB32 Request Version: HTTP/1.0 Host: security.myspace.com\r\n User-Agent: lwp-trivial/1.41\r\n \r\n Hypertext Transfer Protocol POST /index.cfm?fuseaction=invite.addFriendsProcess&Mytoken=88136E +67-DA9F-4FE6-8EDD5377C3F58AE64165334 HTTP/1.1\r\n Request Method: POST Request URI: /index.cfm?fuseaction=invite.addFriendsProcess&My +token=88136E67-DA9F-4FE6-8EDD5377C3F58AE64165334 Request Version: HTTP/1.1 TE: deflate,gzip;q=0.3\r\n Connection: TE, close\r\n Accept-Encoding: identity\r\n Host: collect.myspace.com\r\n Referer: http://collect.myspace.com/index.cfm?fuseaction=invite.ad +dfriend_verify&friendID=107828070\r\n User-Agent: WWW-Mechanize/1.20\r\n Content-Length: 252\r\n Content-Type: application/x-www-form-urlencoded\r\n Cookie: RBLOCKCNT=0; MSCOUNTRY=US; MYUSERINFO=MIICNQYKKwYBBAGCN1gD +pKCCAiUwggIhBgorBgEEAYI3WAMBoIICETCCAg0CAwIAAQICZgMCAgDABAjKZZBb1AJRU +QQQ8EidfzgzBaBIkZHhONOPTASCAeDK%2FEVeQ7RG3t82VDMjQgt2nbAcCzmmiiWt29m1 +wAbDqivIfN11tHVnuaKRxqC64bkVjyCjlNb Cookie2: $Version="1"\r\n \r\n Line-based text data: application/x-www-form-urlencoded hashcode=MIGLBgorBgEEAYI3WAOkoH0wewYKKwYBBAGCN1gDAaBtMGsCAwIAAQICZ +gMCAgDABAgrsahZrvKehgQQanqggVj6eLMO24gaJrq1GwRAF9MwbHHto2HBUAIoZiA3MM +9ZQe97Ag6ob3uGi4N8DHmbFDfVs%2FfBCw3FhriQfFRqAZz99e0mDfmqtvjzJG9ejA%3D +%3D&friendID=107828070&CAPTCHARespo
I've configured my mechanize object like so:
I'm assuming it doesn't work due to the fact that I'm not retrieving the cookies when performing the GET. Does my constructor look correct or am I totally missing something?use WWW::Mechanize; use HTTP::Cookies; my $url = 'http://collect.myspace.com/index.cfm?fuseaction=invite.addf +riend_verify&friendID=107828070'; my $mech = WWW::Mechanize->new(); $mech->cookie_jar( {} ); # login code ... $mech->get($url); # retrieve CAPTCHA image code ... # enter $text code ... $mech->submit_form( form_name => 'addFriend', fields => { CAPTCHAResponse => $text } );
In reply to WWW::Mechanize issue by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |