Skip to content

Instantly share code, notes, and snippets.

@dusk0r
Created March 29, 2017 13:24
Show Gist options
  • Save dusk0r/e1bcbd2a182eb4c4af2d2078f6af6f6c to your computer and use it in GitHub Desktop.
Save dusk0r/e1bcbd2a182eb4c4af2d2078f6af6f6c to your computer and use it in GitHub Desktop.

Revisions

  1. dusk0r created this gist Mar 29, 2017.
    11 changes: 11 additions & 0 deletions digitec-price.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    require 'RestClient'
    require 'nokogiri'

    def getPrice(productId)
    res = RestClient.get "https://www.digitec.ch/de/s1/product/#{productId}"
    doc = Nokogiri::HTML(res.to_s)
    doc.css("#product_reviewed > article .product-price").first.xpath('text()').text.strip.gsub("\u2013", "0").to_f
    end

    productId = '5721031'
    puts "Preis #{productId}: #{getPrice(productId)} Fr."