get thumbnail images from LINE STORE.
$ ruby ./scrape-line-stamp https://store.line.me/stickershop/product/534/ja
/out | |
/vendor |
get thumbnail images from LINE STORE.
$ ruby ./scrape-line-stamp https://store.line.me/stickershop/product/534/ja
# frozen_string_literal: true | |
source "https://rubygems.org" | |
gem "nokogiri" |
GEM | |
remote: https://rubygems.org/ | |
specs: | |
mini_portile2 (2.4.0) | |
nokogiri (1.10.3) | |
mini_portile2 (~> 2.4.0) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
nokogiri | |
BUNDLED WITH | |
1.17.2 |
#!/usr/bin/env ruby | |
require "bundler/setup" | |
require "fileutils" | |
require "nokogiri" | |
require "open-uri" | |
url = ARGV[0] | |
doc = Nokogiri::HTML(open(url)) | |
title = doc.title | |
output_dir = "out/#{title}" | |
FileUtils.mkdir_p(output_dir) | |
# <span class="mdCMN09Image FnPreview" style="background-image:url(https://stickershop.line-scdn.net/stickershop/v1/sticker/19216656/iPhone/[email protected];compress=true);"></span> | |
doc.xpath('//span[@class="mdCMN09Image FnPreview"]').each do |node| | |
# style="background-image:url(https://stickershop.line-scdn.net/stickershop/v1/sticker/19216656/iPhone/[email protected];compress=true);" | |
# https://stickershop.line-scdn.net/stickershop/v1/sticker/19216656/iPhone/[email protected] | |
sticker_url = "#{node["style"][/url\((.+)\)/, 1]}" | |
file_name = output_dir + "/" + sticker_url.sub(/^http(s)*:\/\//, "").gsub(/\//, ".").split(";")[0] | |
open(sticker_url) do |file| | |
open(file_name, "w+b") do |out| | |
out.write(file.read) | |
end | |
end | |
end |