Database Reference
In-Depth Information
How to do it…
Since this is a longer recipe, we'll build it up in segments. At the end, we'll tie
everything together.
Creating the triple store
To begin with, we'll create the triple store. This has become pretty standard. In fact, we'll use
the same version of kb-memstore and init-kb that we've been using from the Reading
RDF data recipe.
Scraping exchange rates
The irst data that we'll pull into the triple store is the current exchange rates:
1. This is where things get interesting. We'll pull out the timestamp. The irst function
inds it, and the second function normalizes it into a standard format:
(defn find-time-stamp
([module-content]
(second
(map html/text
(html/select module-content
[:span.ratesTimestamp])))))
(def time-stamp-format
(formatter "MMM dd, yyyy HH:mm 'UTC'"))
(defn normalize-date
([date-time]
(unparse (formatters :date-time)
(parse time-stamp-format date-time))))
2.
We'll drill down to get the countries and their exchange rates:
(defn find-data
([module-content]
(html/select module-content
[:table.tablesorter.ratesTable
:tbody :tr])))
(defn td->code
([td]
(let [code (-> td
 
Search WWH ::




Custom Search