Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Created January 17, 2012 08:50
Show Gist options
  • Save dongyuwei/1625714 to your computer and use it in GitHub Desktop.
Save dongyuwei/1625714 to your computer and use it in GitHub Desktop.
find the website/blog of github top coder
require 'rubygems'
require 'nokogiri'
require 'net/http'
require 'openssl'
require 'open-uri'
class Net::HTTP
alias_method :origConnect, :connect
def connect
@ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
origConnect
end
end
Blog_links = []
def find_coder_blog_link url
doc = Nokogiri::HTML(open(url))
doc.css('td.owner > a').each do |link|
href = "https://github.com#{link.attribute('href')}"
#puts href
doc = Nokogiri::HTML(open(href))
if doc.css('a.url').length > 0
href = doc.css('a.url')[0].attribute('href')
puts href # name is doc.css('dd.fn')[0]
Blog_links.push(href)
end
end
end
['https://github.com/popular/forked','https://github.com/popular/watched'].each do |url|
find_coder_blog_link(url)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment