News Feed Forums General Web Scraping What data can I scrape from StockX.com sneaker listings using Ruby?

  • What data can I scrape from StockX.com sneaker listings using Ruby?

    Posted by Hirune Islam on 12/20/2024 at 11:49 am

    Scraping sneaker listings from StockX.com using Ruby allows you to extract details such as sneaker names, prices, and popularity. Using Ruby’s open-uri library for HTTP requests and nokogiri for parsing HTML, you can efficiently extract data. Below is an example script for scraping sneaker information from StockX.

    require 'open-uri'
    require 'nokogiri'
    # Target URL
    url = "https://stockx.com/sneakers"
    html = URI.open(url).read
    # Parse HTML
    doc = Nokogiri::HTML(html)
    # Extract sneaker details
    doc.css('.browse-item').each do |item|
      name = item.css('.title').text.strip rescue 'Name not available'
      price = item.css('.price').text.strip rescue 'Price not available'
      popularity = item.css('.popularity').text.strip rescue 'Popularity not available'
      puts "Name: #{name}, Price: #{price}, Popularity: #{popularity}"
    end
    

    This script fetches the StockX sneakers page, parses the HTML using Nokogiri, and extracts sneaker names, prices, and popularity. Pagination can be added to scrape additional pages. Introducing delays between requests helps avoid detection and ensures smooth operation.

    Hirune Islam replied 2 days, 12 hours ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

Log in to reply.