lib/parse_each_page.rb
# process top page of a single restaurant

process top page of a single restaurant
process top page of a single restaurant
def process_single_restaurant_top_page(doc, (prefecture, area1, area2), source_url, scraped_at)
      result = process_single_restaurant_review_page_restaurant_info(doc, source_url, scraped_at)
      return result.merge({
               prefecture: prefecture,
               area1: area1,
               area2: area2,
               has_pr: doc.css(".pr-comment-title").any?,
               search_words: (m = doc.css("meta[name=description]").attribute("content").value.match(/【([^【】]+)】口コミや評価、写真など/); m ? m[1].split("/").map(&:strip).map { |str| str.sub(/あり$/, "") }.join("|") : ""),
             })
    end
def process_single_restaurant_top_page ( doc , ( prefecture , area1 , area2 ) , source_url , scraped_at ) result = process_single_restaurant_review_page_restaurant_info ( doc , source_url , scraped_at ) return result . merge ( { prefecture : prefecture , area1 : area1 , area2 : area2 , has_pr : doc . css ( ".pr-comment-title" ) . any? , search_words : ( m = doc . css ( "meta[name=description]" ) . attribute ( "content" ) . value . match ( / 【([^【】]+)】口コミや評価、写真など/); m ? m[1].split("/").map(&: s t r p . a p { |str| str . s ub( / あ り$/, " " )  }. o n ("| "  :  " "), } ) end
process top page of a single restaurant
process top page of a single restaurant
doc
<not_specific>
prefecture
<not_specific>
area1
<not_specific>
area2
<not_specific>
source_url
<not_specific>
scraped_at
<not_specific>