Created
December 21, 2016 16:07
-
-
Save sergey-alekseev/8df0569cdace955b3fd263a2fadeed1a to your computer and use it in GitHub Desktop.
Скрипт для автоматического поднятия объявлений на Барахолке Онлайнера (http://baraholka.onliner.by)
This file contains 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
# this is a simple Ruby script written by https://github.com/sergey-alekseev | |
# to automate dummy "UP"s for adverts on the most popular local Belarusian | |
# online flea market – http://baraholka.onliner.by | |
# feel free to create a recurring task from the script | |
# using launchd on Mac or cron on Linux | |
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" | |
gem 'watir', '~> 6.0', '>= 6.0.2' | |
# also you need to install a web driver for Selenium to make watir work | |
# Mac: `brew install chromedriver` | |
end | |
require 'watir' # see http://www.rubydoc.info/gems/watir-webdriver | |
browser = Watir::Browser.new | |
# on the login page - authenticate | |
browser.goto 'https://profile.onliner.by/login#login' | |
browser.text_field(type: 'text').set ENV['ONLINER_BY_LOGIN'] # do not forget to set your ENV variables | |
browser.text_field(type: 'password').set ENV['ONLINER_BY_PASSWORD'] # do not forget to set your ENV variables | |
browser.button(type: 'submit').click | |
# on the profile page – go to the flea market adverts page | |
browser.link(text: 'Объявления в барахолке').click | |
# on the flea market adverts page – select all adverts and click 'UP all' | |
browser.link(id: 'select-all-my-adverts').click | |
browser.link(text: 'UP выбранных').click | |
sleep 1 # wait until the action is completed | |
browser.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment