Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
caorong committed Dec 16, 2016
1 parent 60f162d commit 9fbd6ba
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# alfred-workflow-ipip base on ipip.net

an IP query plugin for alfred-workflow(2/3) without any dependence

data is from [ipip.net](https://www.ipip.net/)


# download



# how to use

key work: ip

ip 8.8.4.4

ip ximalaya.com

## screenshots

![1](screenshots/1.png)

![2](screenshots/2.png)

![3](screenshots/3.png)
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ipip.alfredworkflow
Binary file not shown.
49 changes: 49 additions & 0 deletions ipip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh

ip='{query}'

result=$(curl -s https://www.ipip.net/ip.html -H "User-Agent: Safari/537.36" -H "Referer: https://www.ipip.net/ip.html" --data "ip=${ip}" --compressed)

/bin/echo '<?xml version="1.0"?>'
/bin/echo '<items>'

address=`echo "$result" | grep '<div><span id=\"myself\">' -A 1 |tail -n 1| sed "s/<\/span>//g" | sed "s/ //g"`

info=`echo "$result" |grep '<td style=\"text-align: center;\">' | sed -e 's/<[^>]*>//g' | sed "s/ //g" | sed "s/购买此数据//g" |sed "s/(更多数据请购买付费IP库)//g"`

# echo $address
# echo $info

if [[ ! -z "$address" ]]; then
uid=`echo $address | md5 | awk '{print $1}'`
echo '<item uid="'$uid'" arg="'$address'">'
echo '<title>'$address'</title>'
echo '<subtitle>ipip.net 数据</subtitle>'
echo '<icon>icon.png</icon>'
echo '</item>'
fi

if [[ ! -z "$info" ]]; then
uid=`echo $address | md5 | awk '{print $1}'`
echo '<item uid="'$uid'" arg="'$info'">'
echo '<title>'$info'</title>'
echo '<subtitle>IDC 猜测</subtitle>'
echo '<icon>icon.png</icon>'
echo '</item>'
fi


# rtb-asia
rtbresult=$(curl -s "https://ip.rtbasia.com/webservice/ipip?ipstr=${ip}" -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Accept-Language: zh-CN,zh;q=0.8' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Referer: https://www.ipip.net/ip.html' -H 'Cache-Control: max-age=0' --compressed | grep '真人概率' | sed -e 's/<[^>]*>//g' | sed -e 's/&nbsp;//g' |sed "s/ //g"|sed "s/ //g")

# echo "$rtbresult"

if [[ ! -z "$rtbresult" ]]; then
uid=`echo $rtbresult | md5 | awk '{print $1}'`
echo '<item uid="'$uid'" arg="'$rtbresult'">'
echo '<title>'$rtbresult'</title>'
echo '<subtitle>RTBAsia非人类访问量甄别服务</subtitle>'
echo '<icon>icon.png</icon>'
echo '</item>'
fi

Binary file added screenshots/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9fbd6ba

Please sign in to comment.