Skip to content

Instantly share code, notes, and snippets.

@jiskanulo
Last active September 28, 2024 18:04
Show Gist options
  • Select an option

  • Save jiskanulo/364d0bf7b90e07e6917b to your computer and use it in GitHub Desktop.

Select an option

Save jiskanulo/364d0bf7b90e07e6917b to your computer and use it in GitHub Desktop.

Revisions

  1. jiskanulo revised this gist Jun 11, 2019. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions scrape-line-stamp
    Original file line number Diff line number Diff line change
    @@ -14,12 +14,12 @@ title = doc.title
    output_dir = "out/#{title}"
    FileUtils.mkdir_p(output_dir)

    doc.xpath('//span[@class="mdCMN09Image"]').each do |node|
    # style example:"width: 150px; height: 121px; background-image:url(https://sdl-stickershop.line.naver.jp/stickershop/v1/sticker/15832370/android/sticker.png;compress=true); background-size: 150px 121px;"
    # sticker_url example: https://sdl-stickershop.line.naver.jp/stickershop/v1/sticker/15832370/android/sticker.png;compress=true
    # file_name example: sdl-stickershop.line.naver.jp.stickershop.v1.sticker.15832370.android.sticker.png
    sticker_url = "#{node['style'][/url\((.+)\)/, 1]}"
    file_name = output_dir + '/' + sticker_url.sub(/^http(s)*:\/\//, '').gsub(/\//, '.').split(';')[0]
    # <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/sticker@2x.png;compress=true);"
    # https://stickershop.line-scdn.net/stickershop/v1/sticker/19216656/iPhone/sticker@2x.png
    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|
  2. jiskanulo revised this gist Jun 11, 2019. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions scrape-line-stamp
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@

    require "bundler/setup"

    require "fileutils"
    require "nokogiri"
    require "open-uri"

    @@ -10,15 +11,15 @@ url = ARGV[0]
    doc = Nokogiri::HTML(open(url))

    title = doc.title

    Dir.mkdir(title) unless Dir.exists?(title)
    output_dir = "out/#{title}"
    FileUtils.mkdir_p(output_dir)

    doc.xpath('//span[@class="mdCMN09Image"]').each do |node|
    # style example:"width: 150px; height: 121px; background-image:url(https://sdl-stickershop.line.naver.jp/stickershop/v1/sticker/15832370/android/sticker.png;compress=true); background-size: 150px 121px;"
    # sticker_url example: https://sdl-stickershop.line.naver.jp/stickershop/v1/sticker/15832370/android/sticker.png;compress=true
    # file_name example: sdl-stickershop.line.naver.jp.stickershop.v1.sticker.15832370.android.sticker.png
    sticker_url = "#{node['style'][/url\((.+)\)/, 1]}"
    file_name = title + '/' + sticker_url.sub(/^http(s)*:\/\//, '').gsub(/\//, '.').split(';')[0]
    file_name = output_dir + '/' + sticker_url.sub(/^http(s)*:\/\//, '').gsub(/\//, '.').split(';')[0]

    open(sticker_url) do |file|
    open(file_name, "w+b") do |out|
  3. jiskanulo revised this gist Jun 11, 2019. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions scrape-line-stamp
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,9 @@
    #!/usr/bin/env ruby

    require 'open-uri'
    require 'nokogiri'
    require "bundler/setup"

    require "nokogiri"
    require "open-uri"

    url = ARGV[0]

  4. jiskanulo revised this gist Jun 11, 2019. 3 changed files with 22 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions .gitignore
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    /out
    /vendor
    5 changes: 5 additions & 0 deletions Gemfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # frozen_string_literal: true

    source "https://rubygems.org"

    gem "nokogiri"
    15 changes: 15 additions & 0 deletions Gemfile.lock
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    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
  5. jiskanulo revised this gist May 7, 2017. 1 changed file with 11 additions and 2 deletions.
    13 changes: 11 additions & 2 deletions scrape-line-stamp
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,17 @@ doc = Nokogiri::HTML(open(url))
    title = doc.title

    Dir.mkdir(title) unless Dir.exists?(title)
    Dir.chdir(title)

    doc.xpath('//span[@class="mdCMN09Image"]').each do |node|
    system "wget #{node['style'][/url\((.+)\)/, 1]}"
    # style example:"width: 150px; height: 121px; background-image:url(https://sdl-stickershop.line.naver.jp/stickershop/v1/sticker/15832370/android/sticker.png;compress=true); background-size: 150px 121px;"
    # sticker_url example: https://sdl-stickershop.line.naver.jp/stickershop/v1/sticker/15832370/android/sticker.png;compress=true
    # file_name example: sdl-stickershop.line.naver.jp.stickershop.v1.sticker.15832370.android.sticker.png
    sticker_url = "#{node['style'][/url\((.+)\)/, 1]}"
    file_name = title + '/' + 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
  6. jiskanulo revised this gist Dec 15, 2015. 1 changed file with 0 additions and 0 deletions.
    Empty file modified scrape-line-stamp
    100644 → 100755
    Empty file.
  7. jiskanulo revised this gist Dec 14, 2015. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # scrape-line-stamp

    get thumbnail images from [LINE STORE](https://store.line.me/home/ja).

    ## how to use

    ```sh
    $ ruby ./scrape-line-stamp https://store.line.me/stickershop/product/534/ja
    ```

    ## require
    [nokogiri](http://www.nokogiri.org/tutorials/installing_nokogiri.html)
  8. jiskanulo created this gist Dec 14, 2015.
    17 changes: 17 additions & 0 deletions scrape-line-stamp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/usr/bin/env ruby

    require 'open-uri'
    require 'nokogiri'

    url = ARGV[0]

    doc = Nokogiri::HTML(open(url))

    title = doc.title

    Dir.mkdir(title) unless Dir.exists?(title)
    Dir.chdir(title)

    doc.xpath('//span[@class="mdCMN09Image"]').each do |node|
    system "wget #{node['style'][/url\((.+)\)/, 1]}"
    end