Skip to content

Instantly share code, notes, and snippets.

@xuxiaodong
Created July 19, 2012 05:29
Show Gist options
  • Save xuxiaodong/3140962 to your computer and use it in GitHub Desktop.
Save xuxiaodong/3140962 to your computer and use it in GitHub Desktop.
require 'open-uri'
require 'nokogiri'
base_url = 'https://github.com'
url = "#{base_url}/explore"
page = Nokogiri::HTML(open(url))
(1 .. 5).to_a.each do |i|
xpath = "//ol/li[#{i}]/h3/a[2]"
repo = page.search(xpath)
name = repo.text
link = base_url + repo.first['href']
puts "#{i}. #{name} <#{link}>"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment