PHP implementation of Baidu search for a weather thief code _php instance

Source: Internet
Author: User
example, PHP Baidu weather Thief program.

Copy the Code code as follows:
Get the weather information of the search for XX (place name) weather crawl inside Baidu
$url = "Http://www.baidu.com/s?wd=%B1%B1%BE%A9%CC%EC%C6%F8"; This is to search for the return address of Beijing weather in Baidu
$content = file_get_contents ($url);
Preg_match_all ('/(. +?) <\/table>/si ', $content, $temp);
Preg_match_all ('/(. +?) <\/td>/si ', $temp [1][0], $temp 1);
Var_dump ($temp 1[1][0]);

Output information:

String (243) "Beijing weather
Today: Temperature 22 ℃-24 ℃. Daytime: Cloudy, Big shower, night: cloudy. Dongfeng 2-grade to 1-2-stage
Tomorrow: Temperature 23 ℃-28 ℃. Daytime: Cloudy, Evening: cloudy. Southeast Wind Level 2 "

  • 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.