-
-
Save stan/408598 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
%w(rubygems open-uri nokogiri).each { |lib| require lib} | |
doc = Nokogiri::HTML(open('http://xkcd.com/').read) | |
img = doc.at_css("#middleContent img") | |
puts %|Content-type: text/html | |
<html> | |
<head> | |
<title>XKCD for iPad</title> | |
<style type="text/css">BODY { font-family: helvetica; font-size: 16px; text-align: center} | |
.quip { font-style: italic }</style> | |
</head> | |
<body> | |
#{doc.css("h1")} | |
<p>#{img}</p> | |
<p class="quip">#{img[:title]}</p> | |
</body> | |
</html>| | |
# big thanks to selectorgadget.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment