Currently, I am trying to extract the Name, Address, Phone Number, and Email Address of different resorts from certain page(s).
Link to Page
I'm fairly new to Ruby and have been searching for examples, but it seems too specific to find a suitable solution.
My focus right now is on extracting the Email Address. After inspecting the element and noting the CSS path (#category-listings > li:nth-child(1) > div > div > ul > li:nth-child(2) > a)
I have created a ruby script to try to retrieve this data:
require 'nokogiri'
require 'open-uri'
PAGE_URL = "http://www.exploreminnesota.com/places-to-stay/resorts/?keywords=&pageIndex=0&radius=0&mapTab=false&sortOrder=asc&sort=randomdaily&locationid=&startDate=false&class_id=7&lat=&lon=&city=&pageSize=20&type=reitlistings&attrFieldsOr="
page = Nokogiri::HTML(open(PAGE_URL))
site1 = page.css(' #category-listings li:nth-child(1) div div ul li:nth-child(2) a')
puts site1
The output:
href="mailto:**%7B%7Br._source.database_fields.email%7D%7D"** class="button gaTracker" title="**{{r._source.database_fields.email}}**" data-tracker-type="event" data-category="Email" data-label="{{r._source.location.split('/')[1]}}" data-action="{{url | analyticsAction}}">Email
As you can see, instead of the email address, the title displays as : r._source.database_fields.email
When examining this element, the data appears like this:
href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f88e999b998c919796b89f8d9494cc8b9d998b97768bd69b9795">[email protected]</a>" class="button gaTracker" title="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="baccdbd9dbced3d5d4faddcfd6d68ec9dfdbc9d5d4c994d9d5d7">[email protected]</a>" data-tracker-type="event" data-category="Email" data-label="gull-four-seasons-resort" data-action="Places to Stay">Email
I am unsure how to access the data as seen in the browser console. Any guidance would be greatly appreciated, not only helping me understand HTML/CSS better but also how data is extracted onto a page from a database.
Thank you!