Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys, I'm actually developing a project which I will get all the data from a particular website and export it to excel. Does anyone created a php project similar to mine? Please do help me on how to develop it. On the project that i am currently doing, the details can be viewed(details from another website) on my page. How do I save it to a container or straight to the database? Thanks a lot!

Here's the code that I have right now:

PHP
function testVPN()
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://smtracker.pg.com/pls/smtracker/pg_tracker.sm_details?i_id=IM03252634");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    $data = array(
            'i_service' => "FSS SAP",
          'i_max_recs' => ""
    );

    $output = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);

    $check = true;

    if($output == false)
    {
        $check = false;
    }
    return $check;

}

class fss_methods {

function parse_array($beg_tag, $close_tag, $output)
{
preg_match_all("($beg_tag.*$close_tag)siU", $output, $matching_data); //Searches subject for all matches to the regular expression given in pattern and puts them in matches in the order specified by flags.
return $matching_data[0];
}

function curlSM($service){

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://smtracker.pg.com/pls/smtracker/pg_tracker.inc_service");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);

$data = array(
        'i_service' => $service,
      'i_max_recs' => ""
);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

return $output;
}

function AllIncidentInformation($p_service,$p_workgroup){

$class = new fss_methods();
$output=$class->curlSM($p_service);
$container=$class->parse_array('<tr>','</tr>',$output);

$supercontainer=array();

$i = 0;
$fruit=array_pop($container);
foreach ($container as $value){

        $value=trim($value);
        $value= trim(preg_replace('/[^(\x20-\x7F)]*/','', $value) );
        $container[$i]=$value;
        $info=explode('      ', $value);

        foreach ($info as $x){
        //echo $x.'|';

        if(($x == "")||($x == null)||($x == " "))
        {
            echo '****|';
        }
        else
        {
            echo $x.'|';
        }



        }
        echo '<br>';
}

}
}

$class = new fss_methods;

//VPN CONNECTION
$vpn = testVPN();    //check if user is connected to VPN
$vpn_msg = '';
if($vpn == false)
{
    $vpn_msg = "<font color='red'>WARNING: Unable to capture critical tickets. Kindly connect to P&G network.</font><br>";
}else{
    $vpn_msg = "<font color='green'>Good Day! You are now connected to P&G network.</font><br>";
}

echo $vpn_msg;

//echo AllIncidentInformation function
$class->AllIncidentInformation('FSS SAP','G.AFRGSM');

?>


What would be the next step in order to export it? I already have the details but in order to access it, there should be a vpn connection in which i am connected to.
Posted
Updated 4-Dec-14 15:23pm
v3
Comments
DamithSL 3-Dec-14 22:56pm    
you want to save source of the page or complete page with all the resource like images, css, javascripts etc..
what have you tried so far?
tanya de la merced 4-Dec-14 19:36pm    
hi sir! i just need to get the table details, which I already have, but then the details are incomplete i have to add more details which is not included at the table. After which, I need to export it to excel. Thanks!
Sinisa Hajnal 4-Dec-14 2:23am    
There are plenty of examples of how to parse HTML...but without knowing particular page in question, we cannot go into any more details. Also note that you should obtain permission from the site owner before leeching off the content.
tanya de la merced 4-Dec-14 19:38pm    
Hi! I just need to get the details at a particular table from the website. For example; Name, Contact Number, Address, and etc. Thanks!
ZurdoDev 4-Dec-14 7:49am    
You can't just get data from a website. But it sounds like you say you already have the data so I am confused as to what you actually need help with.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900