[SOLVED] Page interaction

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
Morh
Forum Newbie
Posts: 2
Joined: Wed Mar 30, 2005 1:44 am

[SOLVED] Page interaction

Post by Morh »

Hi there, I wonder if you people can help me with a small code I'm trying to make. I'm a newbie when it comes to PHP so don't expect too much of me. Well anyway here we go, I want to make a script that can "interact" with other pages that I don't have access to, for example: there is a postcount on a forum and I wan't to have that number shown on my page or that there is a list of names on a page and I wan't to have them shown on my page. How do I do it?

I'm kinda lost when it comes to thinking up stuff like this but couldn't it be done with fopen() and file_get_contents?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

file_get_contents() will grab the entire page as a single string (if URL wrappers are on)

You can use regular expressions to find the part you want, or ghetto-style strpos() and explode() your way to it ;)
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Just wanted to let you know what Im doing these data grabbing stuff now and its really taking time even on servers.
Using RegExp (preg_match) will take time. Dont use ereg - it takes even more time. file_get_contents() is really fast.
Reduce the number of subpatterns () - that again increases time.
If its one page you are parsing then it'll take a sec but if crawling through many it'll take tremedous amt of time.
Morh
Forum Newbie
Posts: 2
Joined: Wed Mar 30, 2005 1:44 am

Post by Morh »

Ok thanks guys, think I got it now.
Post Reply