Skip to content

Instantly share code, notes, and snippets.

@smallfield
Created July 12, 2020 17:09
Show Gist options
  • Save smallfield/963d5e7d8734a47b46e6ccc61cacec02 to your computer and use it in GitHub Desktop.
Save smallfield/963d5e7d8734a47b46e6ccc61cacec02 to your computer and use it in GitHub Desktop.
buymoテスト
list = {
brand: {selector: "#s_brand dd > a"},
title: {selector: "h1"},
category: {selector: "#s_cate a"},
season: {selector: "#s_season a"},
price: {selector: "#abtest_display_pc"},
info: {selector: ".info_box_wrap span"},
freetext: {selector: "p.free_txt"},
}
res = {}
list.each do |k,v|
res[k] = page.search(v[:selector]).to_a.map(&:text).map(&:strip).join('/')
end
res[:price] = res[:price].tr(/[^\d]/, '')
res
require 'mechanize'
agt = Mechanize.new
page = agt.get("https://www.buyma.com/item/40782299/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment