【发布时间】:2013-11-25 20:00:16
【问题描述】:
我正在编写一个脚本,该脚本具有使用天气 API 的功能。现在我只设法用curl 解决了这个问题,但我最近注意到我无法访问需要运行脚本的curl。有没有其他方法可以解决这个问题?我的代码是这样的:
weatherLondon()
{
echo "<h3>Weather in London</h3>"
(( $# )) || set -- "London,UK"
echo "Location: ${1//,/, }"
curl -s "http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=$1" | perl -ne 's/&deg;/°/g;
s/ \(\d+°F\)//g;
/<title>([^<]+)/ && printf "%s: ",$1;
/<fcttext>([^<]+)/ && print $1,"\n"';
}
我对 bash 和 API 都很陌生
【问题讨论】: