Advertisement
metalx1000

Amazon Price Checker

Jan 22nd, 2019
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2019 Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #This program is free software: you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation version 3 of the License
  9.  
  10. #This program is distributed in the hope that it will be useful,
  11. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. #GNU General Public License for more details.
  14.  
  15. #You should have received a copy of the GNU General Public License
  16. #along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ######################################################################
  18.  
  19. #find product title, price, url on Amazon based on UPC
  20.  
  21. url="https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords="
  22.  
  23. while [ 1 ]
  24. do
  25. echo -n "Scan UPC: ";
  26. read upc;
  27.  
  28. if [ "$upc" = "" ];then echo "Goodbye...";exit;fi
  29.  
  30. results="$(wget "$url$upc" -qO-)";
  31.  
  32. #Get Product Title
  33. product="$(echo "$results"|grep "s-access-detail-page"|sed "s/title=/\ntitle=/g"|grep '^title='|head -n 10|cut -d\" -f2)"
  34.  
  35. if [ "$product" != "" ]
  36. then
  37.  
  38. #output Product Title
  39. echo "$product"
  40. #output Price
  41. echo "$results"|grep 'sx-price-large' -A 3|tail -n 3|sed -e 's/<[^>]*>//g'|sed ':a;N;$!ba;s/\n/./g;s/ //g;s/$./$/'
  42. #output Product URL
  43. echo "$results"|grep "s-access-detail-page"|sed "s/href=/\nhref=/g"|grep '^href='|head -n1|cut -d\" -f2
  44. else
  45. echo "Product Not Found on Amazon"
  46. fi
  47. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement