Jump to content

GET/Remote Website


Lytheum

Recommended Posts

Thanks so much for your help. I looked into the function that you showed me, and it seems that it is the perfect solution but I can't get it working. Here is what I came up with:

[code]$user = 'Zezima';
$webpage = file_get_contents('http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1=' . $user);
$page = strstr($webpage,'Skill');
$table_start = strpos($page, '<table');
$table_end  = strpos($page, '</table>');
print substr($page, $table_start, $table_end - $table_start);[/code]

But for some reason, I think the code just remains in a continuous loop as it never ends up showing me information, just keeps loading.
Link to comment
Share on other sites

[!--quoteo(post=377888:date=May 28 2006, 12:55 PM:name=Lytheum)--][div class=\'quotetop\']QUOTE(Lytheum @ May 28 2006, 12:55 PM) [snapback]377888[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I want to get some data from a table on a remote website and enter the variables into a database of my own. I just need to know how you go about getting the information off of the page.

The page I am trying to 'query' is the following, or something like it:

[a href=\"http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1=zezima\" target=\"_blank\"]http://hiscore.runescape.com/lang/en/aff/r...ws?user1=zezima[/a]

Thanks in advance, if you need anymore info. I'll be sure to get back with it.

EDIT: The info I am trying to pull off of the page is the respective number next to each attribute.

i.e: Overall: Rank 1, Level 2079, 549,728,159 XP
.......Attack: Rank 10, Level 99, 54,441,376 XP
.......etc..
[/quote]
pfft...runescape! ha!.....not possible unless the site alows you! why would you need zezimas score anywasy there all 99...lol...i used to have an account on that game...then i got scammed for 35mill and quit...lol..

Link to comment
Share on other sites

[!--quoteo(post=378555:date=May 30 2006, 07:48 PM:name=legohead6)--][div class=\'quotetop\']QUOTE(legohead6 @ May 30 2006, 07:48 PM) [snapback]378555[/snapback][/div][div class=\'quotemain\'][!--quotec--]
pfft...runescape! ha!.....not possible unless the site alows you! why would you need zezimas score anywasy there all 99...lol...i used to have an account on that game...then i got scammed for 35mill and quit...lol..
[/quote]

Been playing the game for many years, and something has drawn me back to it once again :o

Anyway, there are many people who extract that same data from the website and dynamically create signatures based on it. For example:

[a href=\"http://www.runehq.net/image/dynamic_sig/users/tallsigs/Lytheum.png\" target=\"_blank\"]http://www.runehq.net/image/dynamic_sig/us...igs/Lytheum.png[/a]

Anyways, I still need help if anyone would like to show me how to use preg_match or any other function to find the data I'm looking for. Seems I need to be spoon fed in order to figure it out.

Link to comment
Share on other sites

What exactly are you trying to access an XML feed? If that's the case try fopen and then if you're using PHP 5 you can use simpleXML (or is it simple_xml) which is really easy (duh). If not you'll have to mess around with the xml_parser stuff which isn't so bad just a lot of work. Naturally check out PHP.net to look up how to do that stuff.

If you're not talking about XML then I really don't think you can get what you're looking for. Maybe you can try to fopen/file_get_contents the page and preg match the information?
Link to comment
Share on other sites

Hmm, so I gather it is called 'Screen Scraping'. Well I figured out how to do it from a website that I found via Google. Only now, I get a few errors.

My code:

[code]<?php
// Get page
$user = 'Zezima';
$data= file_get_contents('http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1=' . $user);
// Get content items
preg_match_all "/<div class="mainscroll-content">[^`]*</div>/", $data, $matches;
// Loop through each content item
foreach $matches[0] as $match {
    // Stat
    preg_match "/<a href="overall.ws?table=0&user=zezima">[^`]*</a>/", $match, $temp;
    $stat = $temp[1];
    $stat = strip_tags$stat;
    $stat = trim$stat;

    // Rank
    preg_match "/<td align="right">[^`]*</td>/", $match, $temp;
    $rank = $temp[1];
    $rank = trim$rank;
    
    // Level
    preg_match "/<td align="right">[^`]*</td>/", $match, $temp;
    $level = $temp[1];
    $level = trim$level;

    // Exp
    preg_match "/<td align="right">[^`]*</td>/", $match, $temp;
    $exp = $temp[1];
    $exp = trim$exp;
echo "$stat";
echo "$rank";
echo "$level";
echo "$exp";
?>
[/code]


My error is:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Documents and Settings\HP_Administrator\Desktop\xampp\htdocs\crons.php on line 6[/quote]

I think it's in the way I'm using preg_match all, since I'm suppose to use (). Any help?
Link to comment
Share on other sites

Well for starters your foreach loop needs to be:
[code]
foreach ($matches[0] as $match) {

...

}
[/code]

also you're preg_match_all needs to be something like this:
[code]
preg_match_all($pattern, $string, $match, PREG_MATCH_ORDER);
[/code]
check this out to read more about it
[a href=\"http://us3.php.net/manual/en/function.preg-match-all.php\" target=\"_blank\"]http://us3.php.net/manual/en/function.preg-match-all.php[/a]

Also looking at some of the stuff in your foreach loop, you need to add parentheses to your function calls. ie trim($string)
Link to comment
Share on other sites

Yeah, I guess that's what happens when you attempt to learn php by using other people's code. Sometimes they don't get the code right to start with, and that can cause even more problems for someone like me.

I'll go through it right now adding parentheses (I think that's the problem).

Thanks.

Well, it's working now the only problem is the script goes on forever because it can't find the words that I gave it. This is because when I use quotation marks within the code, it produces an error:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: syntax error, unexpected T_STRING in C:\Documents and Settings\HP_Administrator\Desktop\xampp\htdocs\crons.php on line 6

preg_match_all ("/<div class=[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]"[!--colorc--][/span][!--/colorc--]mainscroll-content[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]"[!--colorc--][/span][!--/colorc--]>[^`]*</div>/", $data, $matches);[/quote]

How do I get around that? I -must- involve quotation marks within the search because that's what the website that I am searching has in it's source.
Link to comment
Share on other sites

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.