Scraping Country Codes, Phone Codes, Dialing Codes, Telephone Codes, ISO Country Codes Using CURL from http://countrycode.org/

How To Scrape http://countrycode.org

If you are looking for simple list of Country Codes, Phone Codes, Dialing Codes, Telephone Codes, ISO Country Codes for your site requirements, i have coded a simple php script to do it.


<?php
    ini_set('max_execution_time', 300); //300 seconds = 5 minutes

        $url = "http://countrycode.org/";
        $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7";

        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($curl, CURLOPT_USERAGENT, $agent);
        $html = curl_exec($curl);
        curl_close($curl);


        $dom = new DOMDocument();
        @$dom->loadHTML($html);
       
        $xpath = new DOMXPath($dom);
       
         $tableRows = $xpath->query('//table//tr');

        foreach ($tableRows as $row) {
            // fetch all 'tds' inside this 'tr'
            $td = $xpath->query('td', $row);
            if ($td->length > 0):
                $res[trim($td->item(0)->textContent)] = "+".preg_replace('/[^a-zA-Z0-9\'\.:]*/i', '',$td->item(2)->textContent) ;
            endif;
            }
       
        print "<pre>";
            print_r($res);
        print "</pre>";

?>


I hope this code will help you.

JQuery : UI Datepicker Enable Specific Dates



$(document).ready(function () {
   
var availableDates = ["4-5-2013","27-5-2013","15-5-2013"];

function available(date) {
 dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
 console.log(dmy+' : '+($.inArray(dmy, availableDates)));
 if ($.inArray(dmy, availableDates) != -1) {
return [true, "","Available"];
 } else {
return [false,"","unAvailable"];
 }
}

$('#start_date').datepicker({
dateFormat: "M d, yy",
numberOfMonths: 4,
minDate: 0,
beforeShowDay: available
});


});


source: http://stackoverflow.com/questions/7709320/jquery-ui-datepicker-enable-only-specific-days-in-array