lib/parse_each_page.rb
# process restaurant information in review page of a single restaurant

process restaurant information in review page of a single restaurant
process restaurant information in review page of a single restaurant
def process_single_restaurant_review_page_restaurant_info(doc, source_url, scraped_at)
      has_station = doc.css(".rdheader-subinfo__item--station").any?
      rating_str = doc.css("#js-header-rating .rdheader-rating__score-val-dtl")[0]&.text&.strip || ""
      status_badge_entry = doc.css(".rdheader-title-data .rdheader-rstname-wrap .rst-status-badge-large")[0]
      status_badge = status_badge_entry && status_badge_entry.attribute("class").value.split(" ").select { |cls| cls.start_with? "rst-st-" }.first.slice("rst-st-".length..-1)
      {
        restaurant_id: doc.css(".js-bookmark[data-rst-id]").attribute("data-rst-id").value,
        restaurant_url: doc.css("meta[property='og:url']").attribute("content").value,
        status_badge: status_badge,
        name: doc.css(".rdheader-title-data .display-name a,.rdheader-title-data .display-name span")[0].text.strip,
        area_name: has_station ? doc.css(".rdheader-subinfo__item--station .linktree .linktree__parent-target-text")[0].text.strip : doc.css(".rdheader-subinfo")[0].css("dl.rdheader-subinfo__item")[0].css(".rdheader-subinfo__item-text")[0].text.strip,
        genre: has_station ? doc.css(".rdheader-subinfo__item--station ~ dl.rdheader-subinfo__item dd.rdheader-subinfo__item-text .linktree .linktree__parent-target-text").map(&:text).map(&:strip).join("、") : doc.css(".rdheader-subinfo")[0].css("dl.rdheader-subinfo__item")[1].css("dd.rdheader-subinfo__item-text .linktree .linktree__parent-target-text").map(&:text).map(&:strip).join("、"),
        rating: rating_str,
        rating_int: rating_str_to_integer(rating_str),
        review_count: doc.css("#js-header-rating .rdheader-rating__review .num")[0].text.strip.to_i,
        dinner_budget: doc.css(".rdheader-budget__icon--dinner .rdheader-budget__price-target")[0].text.strip,
        lunch_budget: doc.css(".rdheader-budget__icon--lunch .rdheader-budget__price-target")[0].text.strip,
        has_holiday_notice: doc.css(".rdheader-subinfo__item-title-ellipsis").any?,
        img_count: doc.css("#rdnavi-photo .rstdtl-navi__total-count strong")[0]&.text&.strip&.to_i || 0,
        has_calendar: doc.css(".rstdtl-side-yoyaku__booking").any?,
        has_pillow_word: doc.css(".rdheader-rstname .pillow-word").any?,
        has_owner_badge: doc.css(".rdheader-rstname .rdheader-official-info .owner-badge").any?,
        has_group_badge: doc.css(".rdheader-rstname .rdheader-official-info .group-badge").any?,
        has_advertisement: doc.css(".rstdtl-side-banner").any?,
        save_target_count: doc.css("#js-header-rating .rdheader-rating__hozon-target .num")[0]&.text&.strip&.to_i || 0,
        source_url: source_url,
        scraped_at: scraped_at,
      }
    end
def process_single_restaurant_review_page_restaurant_info ( doc , source_url , scraped_at ) has_station = doc . css ( ".rdheader-subinfo__item--station" ) . any? rating_str = doc . css ( "#js-header-rating .rdheader-rating__score-val-dtl" ) [ 0 ] &. text &. strip || "" status_badge_entry = doc . css ( ".rdheader-title-data .rdheader-rstname-wrap .rst-status-badge-large" ) [ 0 ] status_badge = status_badge_entry && status_badge_entry . attribute ( "class" ) . value . split ( " " ) . select { | cls | cls . start_with? "rst-st-" } . first . slice ( "rst-st-" . length .. - 1 ) { restaurant_id : doc . css ( ".js-bookmark[data-rst-id]" ) . attribute ( "data-rst-id" ) . value , restaurant_url : doc . css ( "meta[property='og:url']" ) . attribute ( "content" ) . value , status_badge : status_badge , name : doc . css ( ".rdheader-title-data .display-name a,.rdheader-title-data .display-name span" ) [ 0 ] . text . strip , area_name : has_station ? doc . css ( ".rdheader-subinfo__item--station .linktree .linktree__parent-target-text" ) [ 0 ] . text . strip : doc . css ( ".rdheader-subinfo" ) [ 0 ] . css ( "dl.rdheader-subinfo__item" ) [ 0 ] . css ( ".rdheader-subinfo__item-text" ) [ 0 ] . text . strip , genre : has_station ? doc . css ( ".rdheader-subinfo__item--station ~ dl.rdheader-subinfo__item dd.rdheader-subinfo__item-text .linktree .linktree__parent-target-text" ) . map ( & :text ) . map ( & :strip ) . join ( "、")  : d c.c s s(" . rdheader-subinfo")[ 0 ] . c s s(" d l.rdheader-subinfo__item")[ 1 ] . c s s(" d d.rdheader-subinfo__item-text .linktree .linktree__parent-target-text"). m a p(& : t ext). m a p(& : s trip). j o in(" 、 "),
 rating : rating_str , rating_int : rating_str_to_integer ( rating_str ) , review_count : doc . css ( "#js-header-rating .rdheader-rating__review .num" ) [ 0 ] . text . strip . to_i , dinner_budget : doc . css ( ".rdheader-budget__icon--dinner .rdheader-budget__price-target" ) [ 0 ] . text . strip , lunch_budget : doc . css ( ".rdheader-budget__icon--lunch .rdheader-budget__price-target" ) [ 0 ] . text . strip , has_holiday_notice : doc . css ( ".rdheader-subinfo__item-title-ellipsis" ) . any? , img_count : doc . css ( "#rdnavi-photo .rstdtl-navi__total-count strong" ) [ 0 ] &. text &. strip &. to_i || 0 , has_calendar : doc . css ( ".rstdtl-side-yoyaku__booking" ) . any? , has_pillow_word : doc . css ( ".rdheader-rstname .pillow-word" ) . any? , has_owner_badge : doc . css ( ".rdheader-rstname .rdheader-official-info .owner-badge" ) . any? , has_group_badge : doc . css ( ".rdheader-rstname .rdheader-official-info .group-badge" ) . any? , has_advertisement : doc . css ( ".rstdtl-side-banner" ) . any? , save_target_count : doc . css ( "#js-header-rating .rdheader-rating__hozon-target .num" ) [ 0 ] &. text &. strip &. to_i || 0 , source_url : source_url , scraped_at : scraped_at , } end
process restaurant information in review page of a single restaurant
process restaurant information in review page of a single restaurant
# has_pr: ,
 # search_words: ,

doc
<not_specific>
source_url
<not_specific>
scraped_at
<not_specific>