Skip to content

Instantly share code, notes, and snippets.

/phet.rb Secret

Created August 24, 2015 20:59
Show Gist options
  • Save anonymous/f7dc4be782a96f6f4ce7 to your computer and use it in GitHub Desktop.
Save anonymous/f7dc4be782a96f6f4ce7 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'sequel'
require 'mysql2'
require 'mechanize'
require 'open-uri'
agent = Mechanize.new
agent.get('https://fetlife.com/login')
agent.page.form.nickname_or_email = "my_user"
agent.page.form.password = "my_pass"
agent.page.form.submit
agent.page.link_with(:text => 'Porto').click
agent.page.link_with(:text => /(view more).+/).click
agent.page.link_with(:text => /(Next).+/).click
#parsy
noko = agent.page.parser
parsu = noko.css('.clearfix .user_in_list')
parsu.each do | noko |
user = noko.at_css('span').text
age = noko.at_css('.span-8 .quiet').text.to_s.split(' ')[0].to_s.delete('^0-9')
sex = noko.at_css('.span-8 .quiet').text.to_s.split(' ')[0].to_s.delete('0-9')
url = noko.at_css('a')['href']
img = noko.at_css('img')['src']
type = noko.at_css('.span-8 .quiet').text.to_s.split(' ')[1].to_s
puts user
puts age
puts sex
puts url
puts img
puts type
end
agent.page.link_with(:text => /(Next).+/).click
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment