Created
July 12, 2020 17:09
-
-
Save smallfield/963d5e7d8734a47b46e6ccc61cacec02 to your computer and use it in GitHub Desktop.
buymoテスト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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