Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

help with cURL

General discussions related to php

Moderators: macek, egami, gesf

help with cURL

Postby Dewilas » Wed Jan 23, 2013 12:33 pm

Hello,

i need help with table of another site. I need get table value from http://sfl.lt/lenteles/3-omnitel_cup/ site, not first table value but second: "SFL Omnitel taurė B grupė". How this do?
Code: Select all
<?php

$xx = "http://sfl.lt/lenteles/3-omnitel_cup/";
$cURL = curl_init();

curl_setopt($cURL, CURLOPT_URL, $xx);
curl_setopt($cURL, CURLOPT_HEADER,0);

curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cURL, CURLOPT_COOKIESESSION, true);
curl_setopt($cURL, CURLOPT_FOLLOWLOCATION, 1);
$strPage = curl_exec($cURL);
curl_close($cURL);

$strPage = str_replace('dryzuotas', 'spalvotas', $strPage);
$strPage = str_replace('href="/komanda', 'href="http://sfl.lt/komanda', $strPage);
$strPage = str_replace(' odd', 'even', $strPage);
$strPage = str_replace(' even', 'odd', $strPage);
     
   $pattern = "/<(a.*?href=\"[^#])([^>]+)>/";
        $replacement = '<\\1\\2 target="_blank">';
        $strPage = preg_replace($pattern,$replacement,str_replace('target="_blank"','',$strPage));
 
$pattern = '#<table class="inner_table">(.+)</table>#Us';
if( preg_match($pattern, $strPage, $match) ){
    $catch = $match[1];
    echo '<table id="wp-calendar">';
    echo '<caption>SFL Omnitel taurė B grupė</caption>';
    echo $catch;
    echo '</table>';
}else{
    echo 'Could not find it';
}

?>


And second question: how to show only "Vieta" "Komanda" "Varžybos" "Skirtumas" "Taškai" columns value from received table? thank you
Dewilas
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed Jan 23, 2013 12:25 pm

Re: help with cURL

Postby satalways » Thu Jan 24, 2013 6:56 am

You can use these codes..

Code: Select all
$contents = file_get_contents("http://sfl.lt/lenteles/3-omnitel_cup/");
echo $contents;
satalways
New php-forum User
New php-forum User
 
Posts: 5
Joined: Thu Jan 24, 2013 6:39 am
Location: Lahore, Pakistan


Return to PHP General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron