Shell-View Weather

Source: Internet
Author: User

/bin binary Executable command
/sbin System Management commands, which are stored in the hypervisor used by the system administrator
/usr/bin a multitude of applications
/usr/sbin Some management programs for super users


<?php

$city = $argv [1];

$list = [' Shanghai ' = ' 101020100 ', ' beijing ' = ' 101010100 '];

$code = Isset ($list [$city])? $list [$city]: ' 101010100 ';

Initialization

$ch = Curl_init ();

Setting options, including URLs

$URL = "http://www.weather.com.cn/data/cityinfo/". $code. ". HTML ";

curl_setopt ($ch, Curlopt_url, $URL);

curl_setopt ($ch, Curlopt_returntransfer, 1);

curl_setopt ($ch, Curlopt_header, 0);

Execute and get HTML document content

$output = curl_exec ($ch);

Releasing the curl handle

Curl_close ($ch);

Print the obtained data

$data = Json_decode ($output, true);


$GREEN = "\033[1;32m";

$DEFAULT = "\033[0;49m";

$BOLD = "\033[1m";

$UNDERLINE = "\033[4m";

$NORMAL = "\033[m";

$RED = "\033[1;31m";


echo $BOLD. ' Release time: '. $GREEN. $data [' Weatherinfo '] [' ptime ']. $DEFAULT;

echo "\ r \ n";

echo $BOLD. ' Maximum temperature: '. $GREEN. $data [' Weatherinfo '] [' Temp1 ']. $DEFAULT;

echo "\ r \ n";

echo $BOLD. ' Minimum temperature: '. $GREEN. $data [' Weatherinfo '] [' temp2 ']. $DEFAULT;

echo "\ r \ n"

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M01/84/05/wKioL1eDboDjgcAcAABOMxecajA127.jpg "style=" float: none; "title=" 11111111111.jpg "alt=" Wkiol1edbodjgcacaabomxecaja127.jpg "/>

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/84/05/wKioL1eDboCBYQUCAACqGvQTV5g465.jpg "style=" float: none; "title=" 22222222.jpg "alt=" Wkiol1edbocbyqucaacqgvqtv5g465.jpg "/>

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M01/84/06/wKiom1eDboDTE08VAADI1oyN7xo322.jpg "style=" float: none; "title=" 33333.jpg "alt=" Wkiom1edbodte08vaadi1oyn7xo322.jpg "/>

This article is from the "Old Cannon" blog, please be sure to keep this source http://joelemma.blog.51cto.com/11189330/1825493

Shell-View Weather

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.