CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Need help parsing facebook

 



leathan
Novice

Feb 5, 2011, 3:12 AM

Post #1 of 6 (1194 views)
Need help parsing facebook Can't Post

Hi I normally program in Vb.net and am getting a little into perl. I am trying to make a script using a CGI script in perl which connects using the LWP module to facebook.com and parses the data however i cannot even connect to facebook so ill leave out the parsing bit of the code and here is the part of the code that connects, what iswrong? is facebook specifically seeing that im connecting with a script and canceling my connection, what can i do about this?

#!/usr/bin/perl

use CGI qw(:standard);
use LWP;
use HTTP::Cookies; #facebook needs cookies

$browser = LWP::UserAgent->new;
$browser->agent('Mozilla/4.76 [en] (Win98; U)'); #Facebook dont support perl default agent, so spoof this
$browser->cookie_jar(
HTTP::Cookies->new(
file => 'mycookies.txt',
autosave => 1
)
);
$response = $browser->post( 'https://www.facebook.com/login.php?login_attempt=1',
[
'email' => 'leathan7@yahoo.com',
'pass' => '*******', #I edited out my password
], );

print header;
print start_html("What we read...");
print "$pageText 22 "; #This is just to see wtf is goin
print end_html; #on, Argg!!!!!! wtf!!


(This post was edited by leathan on Feb 5, 2011, 3:14 AM)


leathan
Novice

Feb 5, 2011, 9:47 PM

Post #2 of 6 (1162 views)
Re: [leathan] Need help parsing facebook [In reply to] Can't Post

Should I also send all the hidden values that are on the forum? other then that idk

In Reply To


leathan
Novice

Feb 6, 2011, 9:19 PM

Post #3 of 6 (1121 views)
Re: [leathan] Need help parsing facebook [In reply to] Can't Post

Sorry for the triple post but the part of the code

print header;
print start_html("What we read...");
print "$pageText 22 "; #This is just to see wtf is goin
print end_html; #on, Argg!!!!!! wtf!!



Just ignore it i was saving the $response->content in the $pageText variable and then printing it all back just to make sure the script ran well.


budman
User

Feb 10, 2011, 8:34 PM

Post #4 of 6 (1035 views)
Re: [leathan] Need help parsing facebook [In reply to] Can't Post

 
You may want to take extreme caution when scraping Facebook.

If you don't mind your account being suspended, then proceed.
Speaking from experience, I had my acct suspended for 3 months for scraping Mafia Wars game.

Look into using WWW::Mechanize
It does a very good job connecting to sites and entering data into forms.

Regards
Rich


leathan
Novice

Feb 22, 2011, 1:46 PM

Post #5 of 6 (930 views)
Re: [budman] Need help parsing facebook [In reply to] Can't Post

Hey thanks so much for the reply I actually encountered that module before, im going to read it all up now and everything associated with it:D

Also is their an easy way to know what headers a HTTP server is expecting?

I know how to send headers but IDK quite how to understand which ones are being sent to me or which ones are being expected back.

Because i think that is why facebook was rejecting me.

Also thanks for the heads up, luckily i could care less if they deleted my facebook completely id just make another and people would just continue tagging me LOL, i never uploaded one picture and im at 500 O.O!!!

Also i intend on flying under their radar by pretending im trying to follow their robot rules :S

IDK w/e happens idc thanks tho... *OFF TO READ*

Code

In Reply To




EDIT: Also was what i was trying to do before wrong? i thought it would be pretty straightfoward and easy :S


(This post was edited by leathan on Feb 22, 2011, 1:48 PM)


leathan
Novice

Feb 22, 2011, 1:59 PM

Post #6 of 6 (928 views)
Re: [leathan] Need help parsing facebook [In reply to] Can't Post

Okay, I see why its so much better then my way, very nice module idk why i didnt use it, its exactly what I wanted..

In a perfect world it would be object oriented since i cant stand that shit unless its needed due to context.

In Reply To

EDIt:nvm


(This post was edited by leathan on Feb 22, 2011, 4:56 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives