Jump to content

Another Simple XML problem and Where Data is Coming From


jadedknight

Recommended Posts

Ok so I am parsing some XML with SimpleXML. Here is my script so far:

<?php
/**
* Created by PhpStorm.
* User: Chris
* Date: Jul 9, 2010
* Time: 9:04:24 AM
* To change this template use File | Settings | File Templates.
*/

/**
* Cool code snippet to read Blizzards XML
*/
//$xml = file_get_contents($url);
//echo $xml;

/**
* Set some basic constants
* EXAMPLE URL http://www.wowarmory.com/arena-ladder.xml? p=1 ts=2 & b=Vindication
* p = current page
* ts = team_size
* b = battlegroup
*/
ini_set("user_agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
$url = "http://www.wowarmory.com/battlegroups.xml";
$team_size = 2;
$page_count = 1;

/** @var $armory_xml Load the battlegroup XML */
$armory_xml = simplexml_load_file($url);

/**
* Grab the battlegroup url parameters
*/
foreach ($armory_xml->battlegroups->battlegroup as $battlegroup) {
    $ladder_url[] = $battlegroup['ladderUrl'];

    /**
     * Grab the realms for each BG -- not needed at the moment
     */
    //foreach ($battlegroup->realms->realm as $realm) {
    //    $realm_name[] = $realm['name'];
    //}
}

/**
* Go into each BG and into each specified bracket (2v2, 3v3, 5v5) and grab each team over the specified rating
*/
foreach ($ladder_url as $bg_ladder_url) {

    /**
     * Load the BG XML with Simplexml and get the number of pages of teams for that bracket
     */
    $armory_xml = simplexml_load_file("http://www.wowarmory.com/arena-ladder.xml?p=$page_count&ts=$team_size&$bg_ladder_url");
    $page_count = intval($armory_xml->arenaLadderPagedResult['page']);
    $max_page = intval($armory_xml->arenaLadderPagedResult['maxPage']);

    /**
     * For every page, load the XML, get the arena team URL, if rating is below specified amount move on to the next BG
     */
    while ($page_count <= $max_page) {
            $arena_url = "http://www.wowarmory.com/arena-ladder.xml?p=$page_count&ts=$team_size&$bg_ladder_url";
            $arena_xml = simplexml_load_file($arena_url);
            foreach ($arena_xml->arenaLadderPagedResult->arenaTeams->arenaTeam as $arena_team) {
                if (intval($arena_team['rating']) < 2600) {
                    /*
                     * Reset the page count for the next BG
                     */
                    $page_count = 1;
                    break 2;
                } else {
                    // EXAMPLE URL for TEAM XML
                    // http://www.wowarmory.com/team-info.xml? b=Bloodlust& r=Tichondrius& ts=2& t=We+have+ms
                    $team = $arena_team['teamUrl'];
                    $team_url[] = "http://www.wowarmory.com/team-info.xml?$bg_ladder_url&$team";
                }
            }
            $page_count++;
    }
}

foreach ($team_url as $arena_team_xml) {
    $arena_xml = simplexml_load_file($arena_team_xml);
    foreach ($arena_xml->teamInfo->arenaTeam->members->character as $player) {
        $player_list[] = $player['charUrl'];
    }
}

//EXAMPLE Stats page URL http://www.wowarmory.com/character-statistics.xml? r=Daggerspine&cn=Exploitz


?>

 

Here is the next XML page I want to parse:

http://pastebin.com/a1g8LgYQ

 

The data I want is the "arena ratings". If you go to http://www.wowarmory.com/character-statistics.xml?r=Daggerspine&n=Exploitz and navigate to this data you click "Player vs. Player" then "Rated Arenas" and by the use of Javascript on the right hand side the ratings appear. That's the problem! I have no idea how to grab that data or how the Javascript is getting the data. I'm trying to go through all the JS but I still can't find it. Anyone have any ideas?

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.