Jump to content

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

to get the values you would

 

do

<?php

echo $_GET['name'];
echo "<br>";
echo $_GET['check'];
?>

 

this will print

dylandcor2

true

 

of couse you can use them anyway you see fit

 

if thats what you asking if not

 

then try

fread

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..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.