...

View Full Version : Is this possible



juniorx
05-13-2004, 02:58 PM
Ive been reading several clan websites where players are able to retrieve the source code and parse it to get information from a website. For example say i wanted to get the value of "Total Members" from this site: http://www.battle.net/war3/ladder/w3xp-clan-profile.aspx?Gateway=Azeroth&ClanTag=FNS

Is it possible for me to retrieve the source code of this site and use regular expressions to get the number 27

bcarl314
05-13-2004, 03:18 PM
Absolutely! I did that to download over 4000 fonts from one site a while back! So much easier than downloading individual files :D

The basic concept would be...

1) open a file handle and read in the html from the page
2) Parse the page using regular expressions
3) use the data in your site.

NOTE!!! If you're going to incorporate the content in your site, make SURE you GET PERMISSION to do this from the other site first!

juniorx
05-13-2004, 04:02 PM
cool thanks. every clan has been doing it without problem so im guessing i would be allowed. Is there an example of a file handle being used. I don't expect people to do the code for me but just need an example of how to use a file handle for a web page.

bcarl314
05-13-2004, 05:12 PM
Something like this should work...


<?php
###################################
## CONFIGURATION ##
###################################
ini_set("max_execution_time","300"); //script timeout in seconds
###################################
## END CONFIGURATION OPTIONS ##
###################################
function getFile($url) {
$fh = fopen($url,"r");
$d="";
while($data = fgets($fh)) {
$d.=$data;
}
return $d;
}

print "<pre>".htmlentities(getFile("http://www.mysite.com/index.html"))."</pre>";
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum