Help on how to grab data from a page?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm trying to grab our towns restaurant inspection results , store them in a
db ... I have a script that is able to pull the inspections and divides them
by the paragraphs, now I need a way to grab each line (I think) so that I
can hopefully store the data with fields like RestName, RestAddress etc...
(I haven't created the db yet...)
Anyone ever done this?
here is my script so far, it works but I can't seem to get the line br part
to do anything.
_______________________script________________________________________________
<?php


$TESTING = TRUE;


$target_url = "
http://www.springfieldmo.gov/health/database/foodinspections/index.jsp?st_pfx=none&current_name=&start_day=1&end_year=2009&start_month=1&st_nmbr=&end_month=4&end_day=6&Submit=Search&st_name=&start_year=2009&str_loc=none&offset=0
";

$userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';


$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
$html = curl_exec($ch);
if (!$html) {
    echo "<br />cURL error number:" .curl_errno($ch);
    echo "<br />cURL error:" . curl_error($ch);
    exit;
}


// parse the html into a DOMDocument
$dom = new DOMDocument();
@$dom->loadHTML($html);

echo $html;

$graphs = split("<p", $html);

// Start at 6 to clear out junk at top. Use $i+1 since last paragraph
//        is footnote that is not needed.
for ($i = 6; $i+1 < count($graphs); $i++)
{


        if($TESTING)
                echo "$i: $graphs[$i]<br />";

    //split the paragraphs into lines

           $graphs->getAttribute('graphs');
           $lines = split("<br", $graphs);

                //for ($i = 1; $i+1 < count($lines); $i++)
                {
    // Grab restaurant name
                if($TESTING)
                echo "$i: $lines[$i]<br />";
                }
    // Grab address

    // Grab city


    // Grab date and visit type
Thanks
Terion

Happy Freecycling
Free the List !!
www.freecycle.org
Over Moderation of Freecycle List Prevents Post Timeliness.
Report Moderator Abuse Here:
http://www.freecycle.org/faq/faq/contact-info
Or Email Your Complaint to:
faq@xxxxxxxxxxxxx or info@xxxxxxxxxxxxx
------------------------------------------------
Twitter?
http://twitter.com/terionmiller
------------------------------------------------
Facebook:
<a href="http://www.facebook.com/people/Terion-Miller/1542024891";
title="Terion Miller's Facebook profile" target=_TOP><img src="
http://badge.facebook.com/badge/1542024891.237.919247960.png"; border=0
alt="Terion Miller's Facebook profile"></a>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux