#!/bin/bash
# scrape those fucking k2s link sites for shit
# # # # # # # # # #
# malexa is a perv
#
trap "echo Navigate\ to\ file:///tmp/fdom.html\ for\ results" \
SIGINT SIGTERM
# NOTE: this only htmlify's a space tween 2 terms
function fix_query () {
local query
local htmlspace
htmlspace="%20"
query="$1"
if [[ -v $FIXED_QUERY || -z "${query}" ]]; then
unset $FIXED_QUERY
return 0
fi
declare -x "FIXED_QUERY=${query/[[:space:]]/$htmlspace}"
echo "Changed: ${query} to $FIXED_QUERY"
}
# femdom-pov.net is fighting back lel
function make_curl_rc() {
declare -x "FDOMRC=/tmp/.fdomrc"
cat <<EOF > $FDOMRC
user-agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36"
EOF
}
make_curl_rc
if [ -f /tmp/fdom.html ]; then
rm -f /tmp/fdom.html
else
touch /tmp/fdom.html
fi
echo -e "Search femdomcc.org for:\t$1"
declare -i i=1
declare -i MAX=7
while ((i<=MAX)); do
echo -ne "$i.. "
curl -K $FDOMRC --silent -d "do=search&subaction=search&full_search=1&search_start=$i&story=$1" **http**s://femdomcc.org 2>&1 | grep -E ^\<a\ href\=\".*\" >> /tmp/fdom.html || break
let i++
if ((i>MAX)); then
echo -e "\n"
fi
done
let i=i-MAX
echo -e "Search femdom-pov.net for:\t$1"
echo -e "referrer=**http**s://femdom-pov.net/?s=$1" >> "{$FDOMRC}"
fix_query "$1"
while ((i<=MAX)); do
echo -ne "$i.. "
curl -K $FDOMRC --silent "**http**s://femdom-pov.net/page/$i/?s=${FIXED_QUERY}" 2>&1 | python3 -c 'import sys; import lxml.html as lh; d = lh.parse(sys.stdin); lst = lh.tostring(d,pretty_print=True).split(b"\n"); lst = [s.decode("utf-8") for s in lst if b"<a" in s and b"title" in s]; print(str(lst).strip("[]").strip(","))' >> /tmp/fdom.html || break
let i++
if ((i>MAX)); then
echo -e "\n"
fi
done
#fdomrc was modified, reset it
make_curl_rc
#clean up from b4
fix_query ""
echo -e "Done. Navigate to file:///tmp/fdom.html\n\nWARNING: Re-invocation zero\'s out document!" && exit 0