Home >Backend Development >PHP Tutorial >How to implement the function of grabbing weather forecast in PHP_PHP Tutorial

How to implement the function of grabbing weather forecast in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-15 13:32:031054browse

We can use

PHP to grab the weather forecast absolutely streamlined code

  1. < form method="post">
  2. < input name="a" type="text" id="a" />
  3. < input type="submit" name="Submit" value="Check" /> ;
  4. < /form>
  5. < ?php
  6. $city = $_REQUEST["a"];
  7. if ($city=="")
  8. {
  9. $city="描泽";
  10. }
  11. $url = 'http://www.baidu.com/s?wd= '.$city.'Weather'; 🎜>($url); ('', $lines_array);
  12. eregi("Today ((.*)Today’s weather index", $lines_string, $body); $body[0]=strip_tags($body[0]); $body[0] = str_replace("Today’s Weather Index","",$body[ 0]);
  13. $body[0] = str_replace(" ","",$body[0]); echo $city.$body[0]; ?>
  14. The above code example is to capture the weather with PHP How to achieve forecasting.
  15. http://www.bkjia.com/PHPjc/446178.html
  16. www.bkjia.comtrue
  17. http: //www.bkjia.com/PHPjc/446178.htmlTechArticle
  18. We can use PHP to crawl the weather forecast to absolutely streamline the code form method = post input name = a type = text id = a / input type = submit name = Submit value = check / / form ?php $ city...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn