Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Scrapper Incomplete
require 'nokogiri'
doc = Nokogiri::HTML('post.html'))
def extract_usernames(doc)'.comhead > a:first-child').map do |element|
p element.inner_text
# Tittle
p'.title > a:first-child').inner_text
# Post Id
p'.subtext > a:nth-child(3)').map{|link| link['href'] }.join.sub('item?id=', '')
# link for post
p'.title > a:first-child').map{|link| link['href'] }.join
# Number votes
p'.subtext > span').inner_text.sub(' points', '' )
# extract_usernames(doc)
p'.subtext > a:nth-child(2)').inner_text
# Url for the author
p'.subtext > a:nth-child(2)').map{|link| link['href'] }.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment