Class: IndexPDX_Scraper
- Inherits:
-
Object
- Object
- IndexPDX_Scraper
- Defined in:
- lib/scraper.rb
Overview
URI.open(“www.indexpdx.com/adidas/?sort=newest&page=1”)
Class Method Summary collapse
- .brand_list(index_url) ⇒ Object
-
.scrape_brand_index_page_one(index_url) ⇒ Object
scrape all the shoes available for specific brand => array.
- .scrape_jordans_index_page(index_url) ⇒ Object
- .shoe_details(index_url) ⇒ Object
Class Method Details
.brand_list(index_url) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/scraper.rb', line 10 def self.brand_list(index_url) doc = Nokogiri::HTML(open(index_url)) doc.css(".BlockContent .SubCategoryList li").map do |brand| hash = {} hash[:brand_name] = brand.css("a").first.text hash[:brand_href] = index_url.gsub("/adidas/", brand.css("a").first['href']) unless hash[:brand_name].include?("Jason Markk") end binding.pry hash end end |
.scrape_brand_index_page_one(index_url) ⇒ Object
scrape all the shoes available for specific brand => array
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/scraper.rb', line 50 def self.scrape_brand_index_page_one(index_url) doc = Nokogiri::HTML(open(index_url)) doc.css(".ProductList li").map do |shoe| hash = {} hash[:shoe_name] = shoe.css(".ProductDetails a").first.text hash[:price] = shoe.css(".ProductPriceRating em").text hash[:shoe_href] = shoe.css(".ProductDetails a").first['href'] hash end end |
.scrape_jordans_index_page(index_url) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/scraper.rb', line 38 def self.scrape_jordans_index_page(index_url) doc = Nokogiri::HTML(open(index_url)) doc.css(".jordans.clearfix a").map do |editions| hash = {} hash[:name] = editions.css(".jordan-edition p").first.text hash[:href] = index_url.gsub("/jordans/", editions.first.last) hash end end |
.shoe_details(index_url) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/scraper.rb', line 61 def self.shoe_details(index_url) details = Nokogiri::HTML(open(index_url)) hash = {} details.css(".ProductDetailsGrid").each do |detail| hash[:shoe_name] = details.css("h1").text hash[:brand] = details.css(".specs span")[0].text hash[:condition] = details.css(".specs span")[1].text hash[:colorway] = details.css(".specs span")[2].text hash[:year] = details.css(".specs span")[3].text hash[:productid] = details.css(".specs span")[4].text hash[:sizes_available] = details.css(".list-horizontal .name").map { |sizes| sizes.text }.join(', ') end hash end |