Advertisement
harvest316

enum_sugg.sh

Jul 28th, 2012
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.16 KB | None | 0 0
  1. #!/bin/bash
  2. # Adapted from http://automateeverything.tumblr.com/post/22700447516/blekko-keyword-suggest-scraper
  3.  
  4. inp=input.txt
  5. out=output.txt
  6. tmp=tmp.txt
  7. echo "" > $tmp
  8. echo "" > $out
  9.  
  10. while read p; do
  11.     q=$(echo "$p" | sed 's/ /%20/g')
  12.     random=( $(echo '' {a..z} {0..9} | tr " " "\n" | shuf | tr -d " " ) )
  13.     for suffix in '' "${random[@]}"
  14.     do
  15.         echo $p $suffix
  16.         echo ---GOOGLE AUSTRALIA: $p $suffix >> $tmp
  17.         curl -s "http://clients1.google.com.au/complete/search?hl=en&q=$q%20$suffix&client=hp" | sed 's/\\u003Cb\\u003E//g;s/\\u003C\\\/b\\u003E//g;s/\[/\n\[/g' | cut -d'"' -f2 | tail -n +4 >> $tmp
  18.         echo ---AMAZON: $p $suffix >> $tmp
  19.         curl -s "http://t1-completion.amazon.com/search/complete?method=completion&q=$q%20$suffix&search-alias=aps&client=amazon-search-ui&mkt=1&x=updateISSCompletion&sc=1" | sed 's/,\[{".*//g;s/,/\n/g' | cut -d'"' -f2 | grep -v '\[\|\]\|\{\|\]' | tail -n +3 >> $tmp
  20.         echo ---YAHOO PREFIX: $p $suffix >> $tmp
  21.         curl -s "http://sugg.us.search.yahoo.net/gossip-us-ura?droprotated=1&output=sd1&command=$q%20$suffix&nresults=10" | sed 's/{/\n{/g' | grep '"k"' | cut -d'"' -f4 >> $tmp
  22.         echo ---YAHOO SUFFIX: $p $suffix >> $tmp
  23.         # this way uses our keyword as a suffix rather than prefix. usually there are some duplicates with the first method but those are removed later.
  24.         curl -s "http://sugg.us.search.yahoo.net/gossip-us-ura?droprotated=0&output=sd1&command=$q%20$suffix&nresults=10" | sed 's/{/\n{/g' | grep '"k"' | cut -d'"' -f4 >> $tmp
  25.         echo ---BING: $p $suffix >> $tmp
  26.         curl -s "http://api.bing.com/qsonhs.aspx?FORM=ASAPIW&mkt=en-US&type=cb&cb=sa_inst.apiCB&q=$q%20$suffix&cp=13&bq=$q" | sed 's/{/\n{/g' | grep '"Txt"' | cut -d'"' -f4 >> $tmp
  27.         echo ---BLEKKO: $p $suffix >> $tmp
  28.         curl -s "http://blekko.com/autocomplete?query=$q%20$suffix" | sed 's/.*\[//g;s/\].*//g;s/","/\n/g;s/"//g' >> $tmp
  29.         echo >> $tmp
  30.         echo ---THEFIND: $p $suffix >> $tmp
  31.         curl -s "https://www.thefind.com/search/suggest.js?spellcheck=0?&q=$q+$suffix&_output=js" | sed 's/.*\["//g;s/"\].*//g;s/","/\n/g' >> $tmp
  32.         echo >> $tmp
  33.         echo "-----------" >> $tmp
  34.         sleep 1s
  35.     done
  36. done < $inp
  37.  
  38. export LC_ALL=C
  39. sed '/^$/d' $tmp | grep -v "\-\-\-" | sort | uniq > $out
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement