20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/boba_finder_CLI/finder.rb', line 20
def self.scrape_yelp
self.user_zip
doc = Nokogiri::HTML(open(@link, "User-Agent" => "JCS", "From" => "[email protected]"))
doc.xpath("//script").remove
doc.search("li.regular-search-result").map do |spot|
name = spot.css("a.biz-name span").text
stars = spot.css("div.i-stars").attr("title").value
city = spot.css("span.biz-city").children.text if spot.css("span.biz-city")
neighborhood = spot.css("span.neighborhood-str-list").children.text.strip if spot.css("span.neighborhood-str-list")
address = spot.css("address").children.text.strip
telephone = spot.css("span.biz-phone").children.text.strip
BobaFinder::Boba.new(name, stars, city, neighborhood, address, telephone)
end
end
|