-
Notifications
You must be signed in to change notification settings - Fork 0
/
weather.sh
46 lines (40 loc) · 1.24 KB
/
weather.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
# set 命令是 shell 内置命令,用于设置和取消设置 shell 中局部变量的值。
# $ set [--abBCefhHkmnpPtuvx] [-o option] [arg …]
set -eux
# 设置 env
# lang
# https://wttr.in/:translation
LANGUAGE="zh-CN"
CITY=Shanghai
# CITY=Moscow
UNIT=m
# UNIT=u
# m === °C (default)
# u === °F
# temperature
UA="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4343.0 Safari/537.36"
# 文档见 https://github.com/chubin/wttr.in
curl \
-H "Accept-Language: $LANGUAGE" \
-H "User-Agent: $UA" \
-o result.html \
https://v2.wttr.in/$CITY?$UNIT
# "https://v2.wttr.in/$CITY?$UNIT&lang=ru"
# "https://v2.wttr.in/$CITY?$UNIT&lang=ru"
# "https://v2.wttr.in/$CITY?$UNIT&lang=zh-tw"
# https://v2.wttr.in/$CITY?$UNIT&lang=zh
# https://v2.wttr.in/$CITY?$UNIT&lang=zh-cn
# https://v2.wttr.in/$CITY?$UNIT
# v2 local render base64 iamge bug ❌
# https://wttr.in/$CITY?$UNIT
# HHTPS ✅
# wttr.in/$CITY?$UNIT
# HTTP ❌
# http://wttr.in/$CITY?$UNIT
# HTTP ❌
# https://wttr.in/$CITY?format=4\&$UNIT
# https://wttr.in/Shanghai?m
# wttr.in/$CITY?format=4\&$UNIT
# refs
# https://github.com/xgqfrms/weather-email-action/issues/3