-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtx
executable file
·32 lines (21 loc) · 1.2 KB
/
tx
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
#!/bin/sh
if [ $# -le 0 ]; then
echo "Hi, I am Tuxi.. Ask me something"
echo "Usage: tuxi <your question>"
exit
fi
query="$*"
user_agent="lynx"
webpage=$(curl -s -G --compressed "https://www.google.com/search?hl=en_US" --user-agent "$user_agent" --data-urlencode "q=$query")
res0=$(echo "$webpage" | pup 'a.gL9Hy > b text{}' | sed ':a;N;$!ba;s/\n/ /g'| recode html..utf8 )
[ -n "$res0" ] && echo "> u mean $res0?"
list=$(echo "$webpage" | pup 'div.dAassd json{}' | jq -r '.[] | .children | .[] | .text' | sed ':a;N;$!ba;s/\n/ /g' | sed 's/null/\n/g' | awk '{$1=$1;print "* " $0}' | sed '/^* $/d'| recode html..utf8)
[ -n "$list" ] && echo "$list" && exit
res1=$(echo "$webpage" | pup 'div.zCubwf text{}' | tr -d '\n' | recode html..utf8)
[ -n "$res1" ] && echo "$res1" && exit
res2=$(echo "$webpage" | pup 'div.XcVN5d text{}' | recode html..utf8)
[ -n "$res2" ] && echo "$res2" && exit
res3=$(echo "$webpage" | pup 'span.hgKElc text{}' | tr -d '\n' | recode html..utf8 | xargs -d ' ' -n10)
[ -n "$res3" ] && echo "$res3" && exit
tmp=$(echo "$webpage" | pup 'div.kno-rdesc')
[ -z "$tmp" ] && echo "No Result" || (echo "$tmp" | pup 'span' | sed -n '2p' | awk '{$1=$1;print}' | recode html..utf8 | xargs -d ' ' -n10)