Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save admariner/f170949402450fd47b60919b29e09943 to your computer and use it in GitHub Desktop.
Save admariner/f170949402450fd47b60919b29e09943 to your computer and use it in GitHub Desktop.
# Scrape Shopify themes using scrapy.org
#!pip install scrapy
#%%writefile shopify_theme_spider.py
import scrapy
class ShopifyThemeSpider(scrapy.Spider):
name = 'bshopifyspider'
start_urls = ['https://themes.shopify.com/themes?page=1']
def parse(self, response):
for theme in response.css('.theme-info'): # Div
yield {"link": theme.css("a::attr(href)").get(), # A href
'theme': theme.css('a span ::text').get()} #Span text
for next_page in response.css('a.next_page'):
yield response.follow(next_page, self.parse)
# Run using: !scrapy runspider shopify_theme_spider.py -o themes.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment