28, May 2012

using php to get data from another webpage - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: using php to get data from another webpage
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: using php to get data from another webpage  (Read 1602 times)
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« on: Sep 12, 2006, 12:46:52 am »

ok.. what i'm trying to do now is part of a major project. this script needs to be able to find data on a specific webpage, through their hi-scores system (in particular, runescape.com) this will probably require lots of information from runescape's creators themselves.. this needs to be able to query a player name and find all the stats, and put them in an array in which they can be used and updated from time-to-time.. does anyone understand this?

here is an example of the page i want to obtain data from, but instead of this particular username, the username that is requested already in the script itself

Example of Hi-Scores Search Result
« Last Edit: Sep 12, 2006, 12:49:41 am by Meth0d »


Last blog : phpHaze 1.59.1 in Development
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #1 on: Sep 12, 2006, 06:21:34 am »

ok i have found a working script that finds the data from that site, but how would i take this data and write it to my database after retrieving it?

Code:
<?php 
$handle 
fopen("http://hiscore-web.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1=".$_GET['name'],"r"); 
if(
$handle){ 
   while (!
feof($handle)) { 
   
$contents .= fread($handle8192);} 
fclose($handle);}
/////////////////////////////////////////////
/////Cruel's sexy parsing functions./////////
/////////////////////////////////////////////
function GetRank($skill)
{
$str1 strstr($GLOBALS['contents'], '>'.$skill.'<');
if(strpos($str1't"')>40){return '';}
$pos1 strpos($str1't"')+3
return substr($str1$pos1strpos($str1,'<',$pos1)-$pos1);} 
function 
GetLvl($skill)
{
$str1 strstr($GLOBALS['contents'], '>'.$skill.'<');
if(strpos($str1't"')>40){return '';}
$pos1 strpos($str1't"',strpos($str1't"')+1)+3;
return substr($str1$pos1strpos($str1,'<',$pos1)-$pos1);}
function 
GetXP($skill)
{
$str1 strstr($GLOBALS['contents'], '>'.$skill.'<');
if(strpos($str1't"')>40){return '';}
$pos1 strpos($str1't"',strpos($str1't"',strpos($str1't"')+1)+1)+3
return substr($str1$pos1strpos($str1,'<',$pos1)-$pos1);}
function 
parse($skill){return GetRank($skill).'-'.GetLvl($skill).'-'.GetXP($skill);}
echo 
parse(Overall).'|'.parse(Attack).'|'.parse(Strength).'|'.parse(Defence).'|'.parse(Hitpoints) .'|'.parse(Ranged).'|'.parse(Prayer).'|'.parse(Magic).'|'.parse(Cooking) .'|'.parse(Woodcutting).'|'.parse(Fletching).'|'.parse(Fishing).'|'.parse(Firemaking) .'|'.parse(Crafting).'|'.parse(Smithing).'|'.parse(Mining).'|'.parse(Herblore) .'|'.parse(Agility).'|'.parse(Thieving).'|'.parse(Slayer).'|'.parse(Runecraft).'|'.parse(Farming).'|'.parse(Construction);?>




Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #2 on: Sep 12, 2006, 08:01:12 am »

I guess putting those values in the database is the easy part.

Just INSERT into a table the values that you echo in the last line of the snippet you posted Smiley

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #3 on: Sep 12, 2006, 07:42:21 pm »

ok i've got this all figured out Cheesy thanks guys


Last blog : phpHaze 1.59.1 in Development
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #4 on: Sep 15, 2006, 05:50:24 pm »

How is this working for you? I'm looking for something like this myself. I've got some data on one of my sites that is retrieved and viewed, but what I don't like is that this data is not showing up in the search engines because it is displayed thru a javascript...


Last blog : Are You Stumbling Yet?
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #5 on: Sep 15, 2006, 11:28:44 pm »

yeah this script i found gets the correct data no matter what player is requested, if you want a version of it -- PM me Smiley


Last blog : phpHaze 1.59.1 in Development
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=4045
Tags : php javascript databases snippets search engines Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: using php to get data from another webpage
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 04:27:37 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.