Advertisement
J00

ShopifyScrapee.py

J00
Feb 19th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import re
  2. from bs4 import *
  3. import requests
  4.  
  5. ''' This is in python 2 change raw_input to input in python 3'''
  6.  
  7. # Only Website Name (kithnyc, justdon, minishopmadrid, etc)
  8. url = raw_input('Enter Shopify Website: ')
  9.  
  10. # !! IN LOWER CASE ONLY !!
  11. keywords = raw_input('Keyword? ')
  12.  
  13.  
  14. def get_website():
  15.     re_url = requests.get('http://'+url+'.com/sitemap_products_1.xml')
  16.     text = re_url.text
  17.     sauce = BeautifulSoup(text, 'xml')
  18.     for urls in sauce.find_all('url'):
  19.         for location in urls.find_all('loc'):
  20.             for keyword in location.find_all(string=re.compile(keywords)):
  21.                 print (keyword + '\n')
  22.  
  23. get_website()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement