User Tools

Site Tools


code:shell:weather2twitter

Weather to Twitter

#!/bin/sh
 
weather_shanghai=`w3m -dump -no-cookie http://wap.weather.com.cn/wap/weather/101020100.shtml|grep -v "^$"|grep -v "\["|head -n 5|tail -n 3|sed 's/ //g'`
msg=今日天气[上海]:${weather_shanghai}
#echo "msg=${msg}"
 
curl -d "username=xxx&password=xxx&message=${msg}" -k https://216.24.xxx.xxx:8443/HelloServlet/s1/UpdateStatus

Get Weather and PM 2.5

weather_shanghai=`w3m -dump -no-cookie http://www.weather.com.cn/weather/101020100.shtml|grep -A 3 "查看未来"|tail -n 1|sed 's/\(\[.*\]\)//g'|sed 's/  //g'`
pm=`w3m -dump -no-cookie http://www.chapm25.com/city/3#from-chrome|grep "PM2.5为"|cut -d " " -f1`
/var/www/dokuwiki/wiki/data/pages/code/shell/weather2twitter.txt · Last modified: 2016/05/05 13:07 by 127.0.0.1