Using PHP to extract text from a web page?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Starcraftmazter
Forum Commoner
Posts: 45
Joined: Mon Apr 24, 2006 11:36 pm

Using PHP to extract text from a web page?

Post by Starcraftmazter »

Hello

Say there is a webpage, on a website which uses some kind of sessions to keep people logged in.
The page has a lot of stuff on it, and I wish to get only certain things.

Now, correct me if I'm wrong, but couldn't i use PHP socks to connect to this website and then grab the output and put it into a var? From where on, the extraction of information would be as easy as doing various string researches.

The thing I'm not sure on, is how sessions would be handled. This website uses a simple user/pass login, and written in ASP. Sessions don't seem to last long, though I'd say it uses cookies, because it makes like 9 of them.


So yes, if someone could perhaps give me the possibilities of how this can be done - that is initiating or taking advantage of an active session using PHP.


Thanks.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

This is likely against their Terms of Use. I'm only going to give you limited help until you can show me it's not.

To make multiple page requests while gathering output you can use cURL, although make sure you use the same handler across all requests. Then use preg_match() to capture whichever data you want.
Starcraftmazter
Forum Commoner
Posts: 45
Joined: Mon Apr 24, 2006 11:36 pm

Post by Starcraftmazter »

As far as I know it isn't.

http://www.cybernations.net/terms.asp
Post Reply