Stop using cygwin.com for searchall
After reading this message http://cygwin.com/ml/cygwin/2014-05/msg00482.html I set out to find a better option. I found a solution here http://stackoverflow.com/a/10554535 Granted this is a deprecated API, if it actually dies it will be easy enough to replace with a scraper.
This commit is contained in:
parent
81c64c992d
commit
29cd84482b
60
apt-cyg
60
apt-cyg
|
@ -305,21 +305,57 @@ apt-search () {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proxy () {
|
||||||
|
local sd
|
||||||
|
cd /tmp
|
||||||
|
if [ ! -s no_anonim_http.txt ]
|
||||||
|
then
|
||||||
|
wget -q -U ')' 50na50.net/no_anonim_http.txt
|
||||||
|
fi
|
||||||
|
while read px country
|
||||||
|
do
|
||||||
|
if [[ $country != 'United States' ]]
|
||||||
|
then
|
||||||
|
(( sd++ ))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if ! wget -q -T 1 -t 1 -O web.json -e http_proxy=$px "$1"
|
||||||
|
then
|
||||||
|
(( sd++ ))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if grep -q 200 web.json
|
||||||
|
then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
(( sd++ ))
|
||||||
|
fi
|
||||||
|
done < no_anonim_http.txt
|
||||||
|
if (( sd ))
|
||||||
|
then
|
||||||
|
sed -i 1,${sd}d no_anonim_http.txt
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
apt-searchall () {
|
apt-searchall () {
|
||||||
|
local api nof
|
||||||
|
api=ajax.googleapis.com/ajax/services/search/web
|
||||||
for pkg in "${packages[@]}"
|
for pkg in "${packages[@]}"
|
||||||
do
|
do
|
||||||
printf -v qs 'text=1&arch=%s&grep=%s' $ARCH "$pkg"
|
printf \
|
||||||
cd /tmp
|
-v qs 'v=1.0&rsz=8&q="%s"+site:cygwin.com/cygwin/packages/%s' $pkg $ARCH
|
||||||
wget -O matches cygwin.com/cgi-bin2/package-grep.cgi?"$qs"
|
(( nof++ )) && echo
|
||||||
awk '
|
echo getting pages . . .
|
||||||
NR == 1 {next}
|
proxy "$api?$qs"
|
||||||
/-doc-/ {next}
|
grep -q pages web.json || continue
|
||||||
/-debuginfo-/ {next}
|
awk '$2 == "start" {print $4}' RS='[{,]' FS='"' web.json |
|
||||||
/-devel-/ && pkg~/\.exe$/ {next}
|
while read start
|
||||||
/-src\t$/ {next}
|
do
|
||||||
mc[$2]++ {next}
|
echo getting start $start . . . >&2
|
||||||
$0 = $2
|
proxy "$api?$qs&start=$start"
|
||||||
' FS=/ pkg="$pkg" matches
|
awk '$2 == "url" {print $4}' RS=, FS='"' web.json
|
||||||
|
done > urls.txt
|
||||||
|
awk '!s[$7]++ {print $7}' FS=/ urls.txt
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue