Created
August 24, 2016 20:58
-
-
Save anonymous/aa57d0a1f8990375cf3fd30e48469d5a 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 'nokogiri' | |
require 'open-uri' | |
page = Nokogiri::HTML(open('http://bash.org/?browse&p=01')) | |
ql = [] | |
page.xpath('//p[@class="quote"]/a[1]').each do |a| | |
x = a.to_html.gsub('title="Permanent link to this quote."><b>', '').gsub('</b></a>','').gsub('<a href=','').gsub!(/"/, '').split("#") | |
ql.push(x) | |
end | |
puts ql => [["?8 ", "8"], ["?9 ", "9"], ["?10 ", "10"], ["?11 ", "11"], ["?12 ", "12"], ["?13 ", "13"], ["?14 ", "14"], ["?15 ", "15"], ["?16 ", "16"], ["?17 ", "17"], ["?18 ", "18"], ["?19 ", "19"], ["?20 ", "20"], ["?21 ", "21"], ["?22 ", "22"], ["?23 ", "23"], ["?24 ", "24"], ["?25 ", "25"], ["?26 ", "26"], ["?27 ", "27"], ["?28 ", "28"], ["?30 ", "30"], ["?31 ", "31"], ["?32 ", "32"], ["?33 ", "33"], ["?35 ", "35"], ["?36 ", "36"], ["?37 ", "37"], ["?38 ", "38"], ["?39 ", "39"], ["?40 ", "40"], ["?41 ", "41"], ["?43 ", "43"], ["?44 ", "44"], ["?45 ", "45"], ["?46 ", "46"], ["?47 ", "47"], ["?48 ", "48"], ["?49 ", "49"], ["?50 ", "50"], ["?51 ", "51"], ["?52 ", "52"], ["?54 ", "54"], ["?55 ", "55"], ["?56 ", "56"], ["?57 ", "57"], ["?58 ", "58"], ["?59 ", "59"], ["?61 ", "61"], ["?63 ", "63"]] | |
ql.map do |link, i| | |
link.insert(0 ,"http://bash.org/") | |
i.to_i + 1000 | |
end | |
puts ql => [["http://bash.org/?8 ", "8"], ["http://bash.org/?9 ", "9"], ["http://bash.org/?10 ", "10"], ["http://bash.org/?11 ", "11"], ["http://bash.org/?12 ", "12"], ["http://bash.org/?13 ", "13"], ["http://bash.org/?14 ", "14"], ["http://bash.org/?15 ", "15"], ["http://bash.org/?16 ", "16"], ["http://bash.org/?17 ", "17"], ["http://bash.org/?18 ", "18"], ["http://bash.org/?19 ", "19"], ["http://bash.org/?20 ", "20"], ["http://bash.org/?21 ", "21"], ["http://bash.org/?22 ", "22"], ["http://bash.org/?23 ", "23"], ["http://bash.org/?24 ", "24"], ["http://bash.org/?25 ", "25"], ["http://bash.org/?26 ", "26"], ["http://bash.org/?27 ", "27"], ["http://bash.org/?28 ", "28"], ["http://bash.org/?30 ", "30"], ["http://bash.org/?31 ", "31"], ["http://bash.org/?32 ", "32"], ["http://bash.org/?33 ", "33"], ["http://bash.org/?35 ", "35"], ["http://bash.org/?36 ", "36"], ["http://bash.org/?37 ", "37"], ["http://bash.org/?38 ", "38"], ["http://bash.org/?39 ", "39"], ["http://bash.org/?40 ", "40"], ["http://bash.org/?41 ", "41"], ["http://bash.org/?43 ", "43"], ["http://bash.org/?44 ", "44"], ["http://bash.org/?45 ", "45"], ["http://bash.org/?46 ", "46"], ["http://bash.org/?47 ", "47"], ["http://bash.org/?48 ", "48"], ["http://bash.org/?49 ", "49"], ["http://bash.org/?50 ", "50"], ["http://bash.org/?51 ", "51"], ["http://bash.org/?52 ", "52"], ["http://bash.org/?54 ", "54"], ["http://bash.org/?55 ", "55"], ["http://bash.org/?56 ", "56"], ["http://bash.org/?57 ", "57"], ["http://bash.org/?58 ", "58"], ["http://bash.org/?59 ", "59"], ["http://bash.org/?61 ", "61"], ["http://bash.org/?63 ", "63"]] | |
baweaver
commented
Aug 24, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment