Skip to content

Instantly share code, notes, and snippets.

@schappim
Created July 9, 2018 23:28
Show Gist options
  • Save schappim/da7d2cd83e06c46c25128ef4180482d5 to your computer and use it in GitHub Desktop.
Save schappim/da7d2cd83e06c46c25128ef4180482d5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'httparty'
require 'nokogiri'
# Set the URL of the page we want to scrape
url = "https://www.kitronik.co.uk/5632-klip-halo-for-the-bbc-microbit.html"
# Download the webpage
response = HTTParty.get url
# Make the raw HTML response a Nokogiri Document
doc = Nokogiri::HTML response.body
# Get the title
title = doc.search('title').inner_text
# print out the title
puts title
puts
# Get the description
description_html = doc.search('#product_tabs_description_tabbed_contents').first.inner_html.strip
# print out the description HTML
puts description_html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment