ok so i have this script that displays the content of a webpage
what i want to do is parse the name Ozymandias from the $stats string. While trying to build my regex i used a pseudo-code so i could avoide the long load of getting the actual content of the website. The psuedo code is below:Code:<?php
$url = "https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065";
//Gets the content of the submited URL;
$content = file_get_contents($url);
//Strips the tags of the $content;
$strip = strip_tags($content);
//Removes Everything in the up to For:;
$remove = stristr($strip, 'Hawk Down');
//Declares $remove as $getstats;
$stats = $remove;
echo $stats;
?>
the $string is a word for word exerpt from the $stats string in the first code. So i figured I could use $string to test out my regex and when i get it to work just replace the static $string with the dynamic string ($stats). The regex above works fine with the static string but when i encorperated it into the larger script it does not work.Code:<?php
$string = 'Down Ozymandias. Rank: 1-Star General ( 14 ) PCID: A13-3E71AC Player Created: June 9, 2006 TABLE.statsx ';
preg_match('#Down (.*?) Rank#', $string, $matches);
$str = $matches[1];
echo $str;
?>
i have no idea what to do. this is the only thing stoping me from progresing with my program and its a pain! any help is appreciated.Code:<?php
$url = "https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065";
//Gets the content of the submited URL;
$content = file_get_contents($url);
//Strips the tags of the $content;
$strip = strip_tags($content);
//Removes Everything in the up to For:;
$remove = stristr($strip, 'Hawk Down');
//Declares $remove as $getstats;
$stats = $remove;
preg_match('#Down (.*?) Rank#', $stats, $matches);
$str = $matches[1];
echo $str;
?>
thank you!!
Last edited by John; 08-04-2006 at 06:33 PM. Reason: adf
I tried going to the website that you are trying your regex against and it displayed:
https://www.novaworld.com/Players/Search.aspx
Do you have to be logged in to see the page? Perhaps that is why your regex isn't working in PHP.
I have the same problem as Jordan.
Code:for (int i;;) { cout << "Smith"; }
i dont believe you have to be loged in, i just checked it on a different computer in my house and it works fine. Perhaps the website was experience some tech difficulty at the time?![]()
try it again and if it still dont work, type Ozymandias. (with the period) in the search filed and click the icon under the Stats table heading
Same problem for me. I typed Ozymandias. and clicked on the link. It took me to this page:
https://www.novaworld.com/Login.aspx...?UserID=428293
Which is the user logon page.
when you searched did you click on the OzymandiasX link or this image?Originally Posted by NeedHelp
https://www.novaworld.com/Images/xDFBHD_75x75.gif
Clicking the OzymandiasX link will bring up my account information (which you have to be registered to see) clicking the image/icon should allow you to see my stats?
Im almost 100% sure you dont need to log in to see the stats because i can parse 120 other stats on that page from not only my computer but from my webhosting account (which isnt loged in)
I get a "No players matched your search." when searching for Ozymandias.
eh i changed my username, but if you feel like give it another shot i changed it back.
anyway lets look beyond trying to get the script to work on your servers, it works on mine fine except for the regex. I think the problem arrises with the string itself. Obviousally the pattern the regex is trying to parse is different from what is being outputed when i echo the $stats string. (well thats the only thing i can conclude)
So what goes on in these functions that could cause a difference in the actual content verse the echoed content?
$content = file_get_contents($url);
$strip = strip_tags($content);
ok the code below works perfect, but it needs to be cleaned up a bit (dont laugh at my regex abilities)
Code:<?php
$url = "https://www.novaworld.com/Players/Stats.aspx?id=8542545489&p=616065";
//Gets the content of the submited URL;
$content = file_get_contents($url);
//Strips the tags of the $content;
$strip = strip_tags($content);
preg_match('#Down
(.*?)
Rank#', $strip, $matches);
$str = $matches[1];
echo $str;
?>
well it turns out the string was formated like so:
Player Statistics for Delta Force - Black Hawk Down
Ozymandias.
Rank: 1-Star General ( 14 )
so this did the trick:
Code:preg_match('#Down\s+(.*?)\s+Rank#', $strip, $matches);
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks