Jump to content

Grand Exchange PHP


Parsa

Poll  

  1. 1. Poll



Recommended Posts

Been puzzling over this for a while now, i have managed to connect to the hiscores using PHP cURL functions but i cant quite do the same to g.e.

 

 

 

PS although i managed to connect to hiscores using cURL i am really bad at cURL and need much more practise.

 

 

 

The piece of information i am looking for in the source code:

 


Current market price range:




Minimum price: 3





Market price: 4





Maximum price: 5



 

 

 

Taken from the page: http://itemdb-rs.runescape.com/viewitem.ws?obj=9004

 

 

 

Not quite sure how to go about getting that data and turning it into a variable.

Link to comment
Share on other sites

Hey, I'm trying to do the same, My thread:

 

viewtopic.php?f=45&t=784299

 

 

 

If it helps, Heres my code so far (I'm also having problems, with grabbing the price, and displaying it):

 

 

 

<?php

 

 

 

$ch = curl_init();

 

$id = "9004";

 

curl_setopt($ch, CURLOPT_URL, "http://itemdb-rs.runescape.com/viewitem.ws?obj=".$id);

 

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

 

$output = curl_exec($ch);

 

curl_close($ch);

 

 

 

$string = $output;

 

 

 

if(preg_match("/price+(?=:)/", $string, $match))

 

{

 

print_r($match);

 

echo $match[0];

 

}else{

 

echo 'No match found';

 

}

 

 

 

 

 

?>

Link to comment
Share on other sites

<?php

$curlh = curl_init();



curl_setopt($curlh, CURLOPT_URL, 'http://itemdb-rs.runescape.com/viewitem.ws?obj=' . $_GET['id']);

curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);



$src = curl_exec($curlh);



curl_close($curlh);



$item = array();



ereg('Minimum price: ([0-9\.km,])', $src, $item['min']);

ereg('Market price: ([0-9\.km,]+)', $src, $item['mark']);

ereg('Maximum price: ([0-9\.km,]+)', $src, $item['max']);





echo '

Minumim: ' . $item['min'][1] . '


Market: ' . $item['mark'][1] . '


Maximum: ' . $item['max'][1] . '
';

?>

Link to comment
Share on other sites

Hey, I'm trying to do the same, My thread:

 

viewtopic.php?f=45&t=784299

 

 

 

If it helps, Heres my code so far (I'm also having problems, with grabbing the price, and displaying it):

 

 

 

[hide=]<?php

 

 

 

$ch = curl_init();

 

$id = "9004";

 

curl_setopt($ch, CURLOPT_URL, "http://itemdb-rs.runescape.com/viewitem.ws?obj=".$id);

 

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

 

$output = curl_exec($ch);

 

curl_close($ch);

 

 

 

$string = $output;

 

 

 

if(preg_match("/price+(?=:)/", $string, $match))

 

{

 

print_r($match);

 

echo $match[0];

 

}else{

 

echo 'No match found';

 

}

 

 

 

 

 

?>

[/hide]

 

 

 

 

 

Don't hijack threads, jackass.

2257AD.TUMBLR.COM

Link to comment
Share on other sites

  • 1 month later...

You had a silly mistake in your code, thought I would clean that up. :thumbsup:

 

 

 

<?php

$curlh = curl_init();



curl_setopt($curlh, CURLOPT_URL, 'http://itemdb-rs.runescape.com/viewitem.ws?obj=' . $_GET['id']);

curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);



$src = curl_exec($curlh);



curl_close($curlh);



$item = array();



ereg('Minimum price: ([0-9\.km,]+)', $src, $item['min']);

ereg('Market price: ([0-9\.km,]+)', $src, $item['mark']);

ereg('Maximum price: ([0-9\.km,]+)', $src, $item['max']);





echo '

Minumim: ' . $item['min'][1] . '


Market: ' . $item['mark'][1] . '


Maximum: ' . $item['max'][1] . '
';

?>

 

 

 

EDIT: Thank you very much for your help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.