Created
August 1, 2015 13:18
-
-
Save hpetru/5dea8a9a353ea51e7125 to your computer and use it in GitHub Desktop.
Do you have problems with your love life? Is your hand becoming too dry? Ion_The_Conqueror.rb is here to help! Just install ruby and run me, your life will become better just in seconds. Become the most popular person on badoo just by making a few clicks!
This file contains hidden or 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
| source 'https://rubygems.org' | |
| gem 'faraday', '0.9.0' | |
| gem 'faraday_middleware' | |
| gem 'nokogiri' | |
| gem 'pry' |
This file contains hidden or 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 'bundler/setup' | |
| require 'faraday' | |
| require 'nokogiri' | |
| require 'faraday_middleware' | |
| require 'pry' | |
| URL = 'https://eu1.badoo.com/ro-md/' | |
| COOKIES = "PASTE YOUR COOKIES FROM BROWSER HERE!!" | |
| conn = Faraday.new url: URL, headers: {'Cookie' => COOKIES} do |c| | |
| c.use FaradayMiddleware::FollowRedirects, limit: 5 | |
| c.request :url_encoded | |
| #c.response :logger | |
| c.adapter Faraday.default_adapter | |
| end | |
| resp = conn.get 'search' | |
| doc = Nokogiri::HTML(resp.body) | |
| def parse_search_page(doc, conn) | |
| links = doc.css 'a[rel=profile-view]' | |
| successful_count = 0 | |
| links.each do |a_link| | |
| link_url = a_link['href'] | |
| resp = conn.get link_url | |
| doc = Nokogiri::HTML(resp.body) | |
| yes_a_link = doc.at('.js-profile-header-vote[data-choice=yes]') | |
| next unless yes_a_link | |
| yes_url = yes_a_link['data-url'] + '&ws=1&rt=1e1bf5' | |
| resp = conn.get yes_url | |
| puts link_url | |
| successful_count += 1 | |
| end | |
| puts "Links count: #{successful_count}" | |
| end | |
| def get_next_page_url(doc) | |
| next_page_btn = doc.at '.pagination-wrap .pagination .btn:last-child' | |
| next_page_link = next_page_btn.at 'a' | |
| return nil unless next_page_link | |
| next_page_link['href'] | |
| end | |
| 10.times do | |
| url = get_next_page_url(doc) | |
| unless url | |
| puts 'Fuck fuck fuck' | |
| break | |
| end | |
| resp = conn.get url | |
| doc = Nokogiri::HTML(resp.body) | |
| parse_search_page(doc, conn) | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment