swannodette / enlive-tutorial Goto Github PK
View Code? Open in Web Editor NEWAn Easy Introduction to Enlive
An Easy Introduction to Enlive
Hi. I would appreciate an update for this tutorial :) with latest version of deps.
In the scrape1 tutorial, the HN url needs to be changed from (def *base-url* "http://news.ycombinator.com/")
to (def *base-url* "https://news.ycombinator.com/")
in order to work correctly.
The paragraph starting "Your templates do not automatically reload..." could be removed or updated in light of a new auto-reload feature.
Auto-reloading (1.1.2)
(net.cgrand.reload/auto-reload ns)
Each time a resource or file used by a template/snippet is updated the namespace is reloaded (as per (require ... :reload))
It appears that the HTML source of nytimes.com was changed to HTML5 and the div
tags for stories became article
tags. As a result, the *story-selector*
doesn't work anymore. My quick fix is to change :div.story
to :article.story
.
Error Output:
Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see lein help faq
for details.Tried to use insecure HTTP repository without
TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see lein help faq
for details.
title says it all :)
Either
:links (see dummy-context) in the text should be :data or
:data (see defsnippet section-model) in the text and sources should be :links
Completely new to Clojure. Sometimes the examples work, other times I get exceptions (on the same function calls) and I haven't detected a pattern, nor do I know how to resolve these, e.g.:
CompilerException java.lang.RuntimeException: Unable to resolve symbol: hn-headlines-and-points in this context, compiling:(/private/var/folders/sn/n9z1wyp964x889brp42y29yw0000gq/T/form-init3666505936293348284.clj:1:1)
I'd appreciate any pointers.
While playing around with the tutorial I noticed some odd printouts:
=> (print-headlines-and-points)
Porting dl.google.com from C++ to Go (153 points)
DoorDash (YC S13) Delivers Food Quickly In South Bay, Hopes To Expand Beyond Food (23 points)
Free email address validation API for web forms (144 points)
Big-O notation explained by a self-taught programmer (69 points)
The Financial Times on Edward Tufte (61 points)
Apple’s Developer Center Is Back After Over a Week Offline (39 points)
Scientist banned from revealing codes used to start luxury cars (46 points)
They Know Much More Than You Think (18 points)
Superbrothers: Sword & Sworcery sales statistics (62 points)
Simple API with Nginx and PostgreSQL (124 points)
Sellbox – Sell your files from Dropbox and Google Drive with Paypal (68 points)
Hacker Barnaby Jack has died (188 points)
Ashton Kutcher annotates Steve Jobs' 1982 Academy of Achievement speech (16 points)
Did Frank Lloyd Wright create America's greatest office? (61 points)
Kindergarten coders can program before they can read (35 points)
ChessBoardJS (119 points)
Spy agencies ban Lenovo PCs on security grounds (86 points)
My RabbitMQ setup for notifications (78 points)
New edX courses (46 points)
Chinese firm Huawei controls net filter praised by PM (238 points)
Lawmakers Who Upheld NSA Phone Spying Received Double the Defense Industry Cash (79 points)
Donate to Replicant and support free software on mobile devices (31 points)
Android Bug Superior to Master Key (87 points)
How to kill an unresponsive SSH session (165 points)
Report Invalid Whois Contact Information to ICANN? (18 points)
How to slaughter a patent troll in 5 steps (6 points)
Court grants Chevron access to 9 years of email data of activists, critics [pdf] (scribd)
111 points (Feds tell web firms to turn over user passwords)
209 points (Hidden “App Ops” Feature in Android 4.3 Lets You Disable Permissions From Apps)
55 points (Distributed Actors in Java and Clojure)
60 points (More)
nil
It seems like the composite selector, #{[:td.title :a] [:td.subtext html/first-child]}
, is incorrectly selecting bits of the page. By itself it seems fine:
=> (pprint (html/select (fetch-url *base-url*) #{[:td.subtext html/first-child]}))
({:tag :span, :attrs {:id "score_6110398"}, :content ("153 points")}
{:tag :span, :attrs {:id "score_6111110"}, :content ("23 points")}
{:tag :span, :attrs {:id "score_6109905"}, :content ("144 points")}
{:tag :span, :attrs {:id "score_6110671"}, :content ("69 points")}
{:tag :span, :attrs {:id "score_6110602"}, :content ("61 points")}
{:tag :span, :attrs {:id "score_6110858"}, :content ("39 points")}
{:tag :span, :attrs {:id "score_6110575"}, :content ("46 points")}
{:tag :span, :attrs {:id "score_6110993"}, :content ("18 points")}
{:tag :span, :attrs {:id "score_6110005"}, :content ("62 points")}
{:tag :span, :attrs {:id "score_6109069"}, :content ("124 points")}
{:tag :span, :attrs {:id "score_6109649"}, :content ("68 points")}
{:tag :span, :attrs {:id "score_6108217"}, :content ("188 points")}
{:tag :span, :attrs {:id "score_6111050"}, :content ("16 points")}
{:tag :span, :attrs {:id "score_6109626"}, :content ("61 points")}
{:tag :span, :attrs {:id "score_6110230"}, :content ("35 points")}
{:tag :span, :attrs {:id "score_6108628"}, :content ("119 points")}
{:tag :span, :attrs {:id "score_6108980"}, :content ("86 points")}
{:tag :span, :attrs {:id "score_6109077"}, :content ("78 points")}
{:tag :span, :attrs {:id "score_6109775"}, :content ("46 points")}
{:tag :span, :attrs {:id "score_6107313"}, :content ("238 points")}
{:tag :span, :attrs {:id "score_6110595"}, :content ("79 points")}
{:tag :span, :attrs {:id "score_6109916"}, :content ("31 points")}
{:tag :span, :attrs {:id "score_6108469"}, :content ("87 points")}
{:tag :span, :attrs {:id "score_6107553"}, :content ("165 points")}
{:tag :span, :attrs {:id "score_6110307"}, :content ("18 points")}
{:tag :span, :attrs {:id "score_6111012"}, :content ("6 points")}
{:tag :span, :attrs {:id "score_6108061"}, :content ("111 points")}
{:tag :span, :attrs {:id "score_6106940"}, :content ("209 points")}
{:tag :span, :attrs {:id "score_6109897"}, :content ("55 points")}
{:tag :span, :attrs {:id "score_6108556"}, :content ("60 points")})
nil
But with the additional selector:
=> (pprint (html/select (fetch-url *base-url*) #{[:td.title :a] [:td.subtext html/first-child]}))
...
{:tag :a,
:attrs
{:href
"http://m.cnet.com/news/feds-tell-web-firms-to-turn-over-user-account-passwords/57595529"},
:content ("Feds tell web firms to turn over user passwords")}
{:tag :span, :attrs {:id "score_6106940"}, :content ("209 points")}
{:tag :a,
:attrs
{:href
"http://www.droid-life.com/2013/07/26/hidden-app-ops-feature-in-android-4-3-lets-you-selectively-disable-permissions-from-apps/"},
:content
("Hidden “App Ops” Feature in Android 4.3 Lets You Disable Permissions From Apps")}
{:tag :span, :attrs {:id "score_6109897"}, :content ("55 points")}
{:tag :a,
:attrs
{:href
"http://blog.paralleluniverse.co/post/56519815799/distributed-actors-in-java-and-clojure"},
:content ("Distributed Actors in Java and Clojure")}
{:tag :span, :attrs {:id "score_6108556"}, :content ("60 points")}
{:tag :a, :attrs {:href "news2"}, :content ("More")})
nil
I'm using Enlive 1.1.1 and Clojure 1.4.0.
I'm trying to follow along, but (fetch-url *base-url*)
throws an IOException when trying to access https://news.ycombinator.com:
IOException Server returned HTTP response code: 403 for URL: https://news.ycombinator.com/ sun.net.www.protocol.http.HttpURLConnection.getInputStream (HttpURLConnection.java:1615)
I tried changing *base-url*
to http://news.ycombinator.com, but that didn't work. I can access https://news.ycombinator.com normally in my browser.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.