Guys i'm working on a script which is parsing HTML output data from a links with curl.
Here is the HTML DOM parser - http://simplehtmldom.sourceforge.net
Let me show you my parser:
<?PHP
include_once('./simple_html_dom.php');
$url = "http://www.sportsdirect.com/muddyfox-cycling-short-sleeved-jersey-mens-636266?colcode=63626622";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$str = curl_exec($curl);
curl_close($curl);
$html= str_get_html($str);
$SIZEID = 'UK: 8-13 Kids / EU: 25-32 Kids';
$occurencies = preg_match_all('/(?<=\"SizeName\":\"' . preg_quote($SIZEID, "/") . '")\S+/i', $str, $match);
foreach($html->find('#ulColourImages li') as $selectnocolor)
$colvarid = $selectnocolor->colvar-id;
$tooltiptext = $selectnocolor->tooltiptext;
echo "$tooltiptext - $colvarid";
So when i fetch the page that i need i get plain text from which i have to get specific parts.
Here is the complete text: http://pastebin.com/FwK9Z8CP
Let me describe what i need.
In the text there are total 3 occurrences of this specific word ColVarId.
After every ColVarId there are several "SellPrice":"PRICEHERE".
For example in the text "SellPrice":"£4.49" and this SellPrice word is giving me the information about the price. That's all what i want to achieve in final, i want to get the price contained in specific "SellPrice":"MYTargetText"
What i want to do, but don't know how:
For example, I want to get the all text after the second occurrence of ColVarId word and then from the extracted text i want to select for example the third occurence of SellPrice which is in structure like this for example "SellPrice":"£4.49" and in this example the price is 4.49.
So i want to get the price contained there. How can i make it ?
I hope i described my question well and you understand what i want to achieve in final.
Thanks in advance.