Need help at parse in PHP

Grexslo

Newbie
Joined
Oct 20, 2011
Messages
47
Reaction score
2
Hello,
I am neew in PHP but try resolve my problem but I don"t know how to.
Is here someone who can help me parse price in below link:

Code:
[COLOR=#000000][FONT=courier new]<?php[/FONT][/COLOR]
[COLOR=#000000][FONT=courier new]preg_match_all("/Price<\/td><td class\=\"price\">([0-9\.]*?)<\/td/si",file_get_contents('[/FONT][/COLOR]informers.mt5.com/en/quotes_online/informer/sz=540_20&ticker=NZDCHF[COLOR=#000000][FONT=courier new]'), $result);[/FONT][/COLOR]
[COLOR=#000000][FONT=courier new]echo "Price: ";[/FONT][/COLOR]
[COLOR=#000000][FONT=courier new]echo $result[1][0];[/FONT][/COLOR]
[COLOR=#000000][FONT=courier new]?>
[/FONT][/COLOR]

Thanks for all help!
 
I don't see price on the page you're trying to parse at all. Are you sure it's the correct URL?

Also, you need to add http at the start of the URL. You may also want to use PHPQuery—that might make your job slightly easier.

Also, this seems to work (it's not the price, of course, but the td class is the only thing you would need to change I think):

PHP:
<?php
  preg_match_all("/<td class=\"lines\">([0-9\.]*?)<\/td>/si", file_get_contents('http://informers.mt5.com/en/quotes_online/informer/sz=540_20&ticker=NZDCHF'), $result);
  echo "Price: ";
  echo $result[1][0];
  var_dump($result);
?>

I've added var_dump at the end... you should remove it, though it just for testing.
 
Last edited:
Yes, is correct URL. I know that I must put http on link, but I can"t send post with this :)
 
Yes, is correct URL. I know that I must put http on link, but I can"t send post with this :)

Ah, I just made an edit to the previous post. I still don't see the price, but testing it out on another td works just fine.
 
You need regex help, not PHP help.Loading that link, I can't find "price" in the source code of the website, so your regex is wrong.

EDIT: didn't see your edit :)
 
Thanks,
I will use google, but I don"t know what I must :/
 
hello
if you looking for good and very easy parsing technique, you can do search about [h=1]Simple HTML DOM Library[/h]
 
I checked page and I think that for you will be better to parse JSON which is returned:

/quotes_online/ajax/tickers=nzdchf&tz=0&callback=update_quotes

Code:
update_quotes({"status":true,"quotes":{"NZDCHF":{"symbol":"NZDCHF","lasttime":1383260752,"digits":4,"change":"0.0001","bid":"0.7490","ask":"0.7500"}},"time":"20:05"});
 
Back
Top