Last active
June 8, 2018 15:11
-
-
Save MitchRatquest/ffe95334e2dc70a0a70bdc11a536b2f1 to your computer and use it in GitHub Desktop.
using elinks to scrape google for ecommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function scraper() | |
{ | |
#first variable is keyword, second is site you want searched, 3rd is the item number in question | |
URL=$(elinks "https://www.google.com/search?ei=vAXaWsCBL9OSjwSH-YPgBg&q=+"$1"+"$2"+"$3 | grep -i $2 | grep -m1 url?q | sed 's|https://www.google.com/url?q=||g' | sed 's|&sa.*||g' | awk -F' ' '{print $2}') | |
# ^standard web search string ^only site results ^url formatting ^strip google prefix ^strip google suffix ^URL only | |
sleep 5 | |
echo $URL | |
} | |
function iterator() | |
{ | |
while read p; do | |
scraper $1 $2 $p | |
done < $3 | |
} | |
iterator $1 $2 $3 | |
#^ keyword site file of newline seperated item numbers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment