Forum Moderators: coopster

Message Too Old, No Replies

Scanning information from a page?

Give PHP the url, can it do the rest?

         

Tokey

8:21 pm on Aug 5, 2003 (gmt 0)

10+ Year Member



Hello,
I'm looking to write a script that would scan a page at a user-specified url and display all of the links on that page. Sort of like how a search engine spider organizes information out of pages. Is this possible using PHP?
Any suggestions on where to start would be appreciated!

--Tokey

jatar_k

8:23 pm on Aug 5, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



sure two things that come to mind are fsockopen [ca.php.net] and curl [ca.php.net].

Tokey

9:21 pm on Aug 5, 2003 (gmt 0)

10+ Year Member



Thank you! That is exactly what I was looking for.

blah, now i've hit another wall... I have the contents of a page stored to a variable, but I don't know what functions to use to remove everything but <a> tags and their contents from the variable.

any suggestions?

bcolflesh

9:46 pm on Aug 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



preg_replace or str_replace - PHP.net is down for me right now, or I would have linked.

vincevincevince

10:53 pm on Aug 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




$text=preg_replace("/[^\[\]]*\[([^\¦]*)\¦([^\]]*)\][^\[]*/i","$1 $2<br>",preg_replace("/<[^\>]*a[^\>][^\>]*href[^\>]*=\s*([\"']?[^\>]*[\"']?)[^\>]*\>([^\<]*)\<[^\>]*\/a[^\>]*>/i","[$1¦$2]",$text));

(tested - don't forget to turn ¦ into a real pipe)