Created
September 17, 2014 06:49
-
-
Save soramugi/4981018c39f6e775eb2b 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
require 'sinatra' | |
require 'open-uri' | |
require 'nokogiri' | |
get '/' do | |
url = "http://negineesan.com" | |
@imgs = [] | |
doc(url).xpath('//p[@align="left"]/a').each do |a| | |
num = a[:href].gsub(/[^0-9]/, '').to_i | |
num = "%03d" % num | |
@imgs << "http://negineesan.com/comics/negi/negi#{num}.jpg" | |
end | |
erb :index | |
end | |
def doc(url) | |
charset = nil | |
html = open(url) do |f| | |
charset = f.charset | |
f.read | |
end | |
Nokogiri::HTML.parse(html, nil, charset) | |
end | |
__END__ | |
@@ layout | |
<html> | |
<head> | |
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script> | |
<script type="text/javascript" src="//raw.githubusercontent.com/tuupola/jquery_lazyload/master/jquery.lazyload.min.js"></script> | |
</head> | |
<body> | |
<%= yield %> | |
</body> | |
</html> | |
@@ index | |
<div id="imgs"> | |
<% @imgs.each do |img| %> | |
<img class="lazy" data-original="<%= img %>" height="100%"> | |
<br /> | |
<% end %> | |
</div> | |
<script> | |
$(function() { | |
$("img.lazy").lazyload(); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ruby negi.rb