Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Cities I tested:
- #Contagem: 3465624
- #Belo Hor: 3470127
- #Tokyo : 1850147
- #Paris : 2988507
- #Betim : 3470044
- cityId=1850147
- url=http://openweathermap.org/city/$cityId
- source=$(curl -s $url)
- echo "---------------------"
- echo "Weather Catcher :D"
- echo "---------------------"
- city=$(echo "$source" | grep -Pzo "<div class=\"weather-widget\">\n+<h3>.+</h3>" | tail -n1 | cut -d'>' -f2 | cut -d'<' -f1)
- echo "City: "$city
- temp=$(echo "$source" | grep -Pzo "<div class=\"weather-widget\">\n+<h3>.+</h3>\n+<h2>.+<img.+>" | tail -n1 | cut -d'>' -f3 | cut -d'<' -f1)
- echo "Temperature: "$temp
- windComplete=$(echo "$source" | grep -Pzo "<td>Wind</td><td>.+<br>\n.+\n</td>")
- wind1=$(echo $windComplete | grep -Eo "</td><td>.+<br>" | cut -d'>' -f3 | cut -d'<' -f1)
- wind2=$(echo $windComplete | grep -Eo "<br>.+" | cut -d'>' -f2 | cut -d'<' -f1)
- echo "Wind: "
- echo " Desc: "$wind1
- echo " Dir : "$wind2
- cloud=$(echo "$source" | grep -E "Cloudiness" | cut -d'>' -f5 | cut -d'<' -f1)
- echo "Cloudiness: "$cloud
- pressure=$(echo "$source" | grep -E "Pressure<br>" | cut -d'>' -f6 | cut -d'<' -f1)
- echo "Pressure: "$pressure
- humidity=$(echo "$source" | grep -E "Humidity" | cut -d'>' -f5 | cut -d'<' -f1)
- echo "Humidity: "$humidity
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement