小编use*_*840的帖子

刮板php返回一个空白页面

我是php新手,我已经制作了一个scraper.php页面,您可以从" http://www.weather-forecast.com "中查找任何特定城市的天气信息.
我正在跟随教师,我无法理解为什么我的代码返回一个空白页面,它应该只返回一个简短的3天预测

无论如何......这是我的代码

<?php
$city=$_GET['city'];
$city=str_replace(" ","",$city);
$contents=file_get_contents("http://www.weather-forecast.com/locations/".$city."/forecasts/latest");
preg_match('/3 Day Weather Forest Summary:<\/b>
<span class="phrase">(.*?)</span>',$contents, $matches);
echo $matches[1];
?>
Run Code Online (Sandbox Code Playgroud)

php file-get-contents str-replace

5
推荐指数
1
解决办法
112
查看次数

标签 统计

file-get-contents ×1

php ×1

str-replace ×1