PDA

View Full Version : Fetching Content from URLs off an External URL


John_Saunders
09-08-2002, 10:23 PM
I am trying to build a page that lists info off another web page through SSL, so I can have it displayed on my own site instead of having to login to the other site to see the data. I am using Snoopy (http://sourceforge.net/projects/snoopy/) to fetch the content but I cannot figure out how to accomplish what I need to do.

I have a page that I can log into that displays about 150 URLs that change about once a day. I need to pull information from each link like a person's name and e-mail address, but I can't figure out how to get it to go to each page.

This is the code that I'm using that will create a page on my site with all the links:

<?php
include "snoopy.class.inc";
$snoopy = new Snoopy;
if($snoopy->fetchlinks("https://userid:password@www.domain.com/index.php?OrderBy=Name&DisplayLive=1&DisplayNormal="))
{
while(list($key,$val) = each($snoopy->results))
echo $key.": ".$val."<br>\n";
echo "<p>\n";
echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
}
else
echo "error fetching document: ".$snoopy->error."\n";
?>

I'm sure I'll be able to figure out how to pull the content that I need off the subpages, I just need some help getting it to go to each subpage by following the URL on the page. If someone who is familiar with Snoopy or is very good with PHP can take a look at the program at the link above, it may not be that hard to do.

I hope this make sense but if not, please let me know and I'll try to explain it a little better.


John

firepages
09-09-2002, 08:02 AM
just use a callback (I am assuming that these are http links and not maito's ??)



<?php

function get_this($url){
include_once("snoopy.class.inc");
$yaks=new Snoopy;
$yaks->fetch($url);
echo $yaks->results;//or save to file/whatever
}

include "snoopy.class.inc";
$snoopy = new Snoopy;
if($snoopy->fetchlinks("https://userid:password@www.domain.com/index.php?OrderBy=Name&DisplayLive=1&DisplayNormal="))
{
while(list($key,$val) = each($snoopy->results))
echo $key.": ".$val."<br>\n";
get_this($val);
}
else
echo "error fetching document: ".$snoopy->error."\n";
?>


not tested but you see the idea?