Jump to content

[SOLVED] Getting Data from Another Page


dylandcor

Recommended Posts

Is there any way I could get the information from this page (http://www.mapletip.com/rankcapture.php?name=dylandcor2&check=true) such as level and experience into a variable so I can use it to create an image.  The page that is linked isn't mine, so I don't know how it is set up.  I know how to create the image, I just can't seem to get all of the data out of the page. 

 

Any help would be appreciated!

Link to comment
https://forums.phpfreaks.com/topic/48503-solved-getting-data-from-another-page/
Share on other sites

Thank you for the quick reply, but your $_GET idea didn't work, seeing as I don't know what the site called the variables.  I also just tried this code

<?php
$filename = "http://www.mapletip.com/rankcapture.php?name=dylandcor2&check=true";

$file = fopen($filename, "r");
$size = filesize( $file );
$text = fread($filename, $filesize);
fclose($filename);
echo $text;
?>

  And it gave me this error:

 

 

Warning: filesize() [function.filesize]: stat failed for Resource id #3 in C:\Documents and Settings\Dylan\Desktop\html\get.php on line 5

 

Warning: fread(): supplied argument is not a valid stream resource in C:\Documents and Settings\Dylan\Desktop\html\get.php on line 6

 

Warning: fclose(): supplied argument is not a valid stream resource in C:\Documents and Settings\Dylan\Desktop\html\get.php on line 7

well this may work

 

of course $subject = the data

 

<?php
$subject = "blarassgdyasdg sdgyasud Level: 49 gdsdjg ashd gashd gsahd gsahj";

if (preg_match('/Level: (\\d+)/', $subject, $regs)) {
$result = $regs[1];
}

echo "$result<br />";
?>

Ok, That works great, just one more question, and then I think this topic is solved.  Using your code, if I want all of the data, how do I go about changing the variables in your code so I could find the name of the character, the experience and such?

 

Also, what exactly is the $regs variable?

 

My code so far:

 

<?php
$filename = "http://www.mapletip.com/rankcapture.php?name=dylandcor2&check=true";
$file = file_get_contents($filename);

if (preg_match('/Level: (\\d+)/', $file, $regs)) {
$result = $regs[1];
}
echo "The Level is $result<br />";
?>

sorry about that needed a break

 

OK, this works pretty well

 

<?php


$filename = "http://www.mapletip.com/rankcapture.php?name=dylandcor2&check=true";
$file = file_get_contents($filename);

if (preg_match('/Rank: (\\w+).*Name: (\\w+).*World: (\\w+).*Job: (\\w+).*Level: (\\w+).*Experience: ([0-9,]*).*Movement: (\\w+ (?:\\w+)?)/sm', $file, $regs)) {

$Rank = $regs[1];
$Name = $regs[2];
$World = $regs[3];
$Job = $regs[4];
$Level = $regs[5];
$Experience = $regs[6];
$Movement = $regs[7];

echo "The Rank is $Rank<br />";
echo "The Name is $Name<br />";
echo "The World is $World<br />";
echo "The Job is $Job<br />";
echo "The Level is $Level<br />";
echo "The Experience is $Experience<br />";
echo "The Movement is $Movement<br />";
}

?>

 

 

as for the regs they are results from RegularExpressions aka RegEx, something i have been praticing with..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.