Forum Moderators: coopster

Message Too Old, No Replies

Searching Withing A Page Not On Your Site

How?

         

inuwolf

5:41 pm on Mar 25, 2006 (gmt 0)

10+ Year Member



I'd like to make a web app that scans a web page for images URLS and then prints all their images to the result page. The catch: it would scan other sites. Ideally, you could just enter a URL, your PHP file would somehow read that page's code and print the results.

Is this possible? How? (I really only need help opening their webpage, from there I could write the script.)

inuwolf

7:12 pm on Mar 25, 2006 (gmt 0)

10+ Year Member



Nevermind, fopen. Now, how to query a document...

jatar_k

7:31 pm on Mar 25, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you can't query it per se

you need to read through it and look for what you want

inuwolf

8:47 pm on Mar 25, 2006 (gmt 0)

10+ Year Member



I've made a form that checks a URL you submit by opening or closing the file. If it doesn't open it prints "URL not valid" but otherwise it goes ahead and puts the file into an array and a string:

$htmlarray = file($file);
$htmlstring = implode('', $htmlarray);

So, in the array I'm looking for all values that have .jpg in them so I can print them, and only them, as pictures. Is there any way to do a preg search for the values in an array, so that every value in the array with .jpg in it is printed?

The hardest part of being a beginner is not knowing the limitations of PHP: Is there a function for this? Can PHP do that? Ugh...

coopster

11:01 pm on Mar 26, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Why not go with file_get_contents() [php.net] since that reads the entire file into a string for you right off. Next, use preg_match_all() [php.net] to capture all the images found in that string into an array.