Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-04-2006, 08:57 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default regex (yuck)

ok so i have this script that displays the content of a webpage
PHP 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;
?>
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:
PHP 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;
?>
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.

PHP 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;

?>
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.

thank you!!

Last edited by John; 08-04-2006 at 09:33 PM. Reason: adf
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 08-05-2006, 03:10 PM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,203
Last Blog:
Ext JS or Ext GWT
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

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.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-05-2006, 11:16 PM
smith smith is offline
Programmer
 
Join Date: Jun 2006
Posts: 108
Rep Power: 9
smith is on a distinguished road
Default

I have the same problem as Jordan.
__________________
Code:
for (int i;;) {
   cout << "Smith";
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-06-2006, 02:11 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-06-2006, 09:54 PM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Rep Power: 13
NeedHelp is on a distinguished road
Default

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.
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 08-06-2006, 10:54 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

Quote:
Originally Posted by NeedHelp
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?

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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 08-07-2006, 08:52 PM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,203
Last Blog:
Ext JS or Ext GWT
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

I get a "No players matched your search." when searching for Ozymandias.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-08-2006, 12:22 AM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

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);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 08-08-2006, 09:46 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default Update

ok the code below works perfect, but it needs to be cleaned up a bit (dont laugh at my regex abilities )

PHP 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;
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 08-09-2006, 01:35 AM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

well it turns out the string was formated like so:


Quote:
Player Statistics for Delta Force - Black Hawk Down










Ozymandias.
Rank: 1-Star General ( 14 )

so this did the trick:
PHP Code:
preg_match('#Down\s+(.*?)\s+Rank#'$strip$matches); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: C# Regex NeedHelp CSharp Tutorials 2 05-01-2007 07:44 AM


All times are GMT -5. The time now is 05:01 AM.