-
Notifications
You must be signed in to change notification settings - Fork 4
/
cnbeta-mobile-news.sh
executable file
·59 lines (44 loc) · 1.24 KB
/
cnbeta-mobile-news.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
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
script_dir=$(dirname "$0")
source "$script_dir/common.sh"
# BusyBox 里的 awk 貌似已经是以字节为单位的了 (也许跟 LANG 环境变量为空有关?),
# 如果是 gawk 的话,可能需要指定 -b / --characters-as-bytes 参数
cnbeta=$(wget -O - http://m.cnbeta.com/wap | grep 'a href="/wap/view/' | awk -F= "$(cat $script_dir/functions.awk)"'
BEGIN { init_char_int_index(); }
{
debug=1
# 删除前面的 div 元素 <div class="list">
tmp=substr($0,19);
# 继续删除前面的 a 元素 <a href="/wap/view/333623.htm">
left=index(tmp,">");
tmp=substr(tmp, left+1);
# 删除后面的 a 元素闭合
right=index(tmp,"<")-1;
tmp=substr(tmp,1,right);
# 删除 [, ] 替换为空格
gsub("\\[","",tmp);
gsub("\\]"," ",tmp);
# 保证长度不超过 32 字节
if (length(tmp) > 32)
tmp=substr(tmp, 1, 32);
if (debug) print "[" tmp "]" > "/dev/stderr";
tmp=fix_utf8_truncation(tmp);
print tmp;
}');
#echo ------------------------
#echo "$cnbeta"
#echo ------------------------
i=0
IFS=$'\n'
for n in $cnbeta
do
iface_index=${array_wifi_iface_indexes[$i]}
#echo "[$n]"
uci set wireless.@wifi-iface[$iface_index].ssid="$n"
((i++))
if [[ $i -ge ${#array_wifi_iface_indexes[@]} ]]
then
break;
fi
done
uci commit && wifi