You are here: Re: Pulling date-specific data from flat file « PHP Programming Language « IT news, forums, messages
Re: Pulling date-specific data from flat file

Posted by pangea33 on 11/01/06 10:03

Let's say your target page, is this pretty decent sized document at
W3.org: http://validator.w3.org/docs/users.html

View the page source manually to find some unique portions that
delineate the important section, and plug them into the $cStartStr and
$cEndStr variables. For this exercise I chose to extract the section
labeled "Interpreting the results".

<?php
$cTargetPage = "http://validator.w3.org/docs/users.html";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $cTargetPage);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);

$cPgStr = curl_exec($ch);
curl_close($ch);

$cStartStr = "<div id=\"Interpret\" class=\"stb\">";
$cEndStr = "</div>";
$cPageTail = stristr($cPgStr, $cStartStr);
$nUsefulDataEndPos = strpos($cPageTail, $cEndStr);
$cUsefulData = substr($cPageTail, 0, $nUsefulDataEndPos+6);
echo($cUsefulData);
?>

Run the script and save the relevent portion somewhere useful instead
of echoing it out. :-)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация