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
#encoding: utf-8 | |
require 'watir-webdriver' | |
require './spec/public_function' | |
describe 'Delete Post' do | |
before :all do | |
puts 'start browser' | |
@b = Watir::Browser.new :chrome | |
@password = @user_name = 'admin' | |
end |
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
#encoding: utf-8 | |
require 'watir-webdriver' | |
describe 'Create Post' do | |
before :all do | |
puts 'start browser' | |
@b = Watir::Browser.new :chrome | |
# 如何在watir里面使用原生的webdriver | |
#@b.wd == Selenium::WebDriver.for(:chrome) | |
@password = @user_name = 'admin' |
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
#encoding: utf-8 | |
require 'watir-webdriver' | |
describe 'Create Post' do | |
before :all do | |
puts 'start browser' | |
@b = Watir::Browser.new :chrome | |
@password = @user_name = 'admin' | |
end |
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
#encoding: utf-8 | |
class Employee | |
WORK_DAY_OF_MONTH = 20 | |
DOUBLE = 2 | |
attr_reader :name, :pay_per_day | |
def initialize name, pay_per_day | |
@name = name | |
@pay_per_day = pay_per_day | |
@pay_off = @over_time = 0 | |
end |
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
#encoding: utf-8 | |
class Phone | |
attr_reader :type, :has_keyboard | |
def initialize(type, has_keyboard) | |
# 型号 | |
@type = type | |
# 键盘 | |
@has_keyboard = has_keyboard | |
end |
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
require 'optparse' | |
require 'watir-webdriver' | |
ENV.delete('HTTP_PROXY') | |
module Inter | |
def self.parse | |
opts = {} | |
opts[:from] = 'qq' | |
opts[:browser] = 'chrome' | |
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
#encoding: utf-8 | |
# print all the inter news with waitr-webdriver | |
require 'watir-webdriver' | |
url = 'http://sports.qq.com/seriea/' | |
b = Watir::Browser.new :chrome | |
b.goto url | |
b.div(:id, 'inter').div(:class, 'hot_list').links.each do |link| |
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
#encoding: utf-8 | |
# 文件名 tuoshui.rb | |
# 将天涯易读的帖子中的内容抓出来并打印 | |
# 使用方法: | |
# ruby tuoshui.rb [天涯易读帖子id] > result.txt | |
# 如果没有在运行脚本时指定帖子id的话,默认id为40489 | |
require 'watir-webdriver' | |
def build_url(id) | |
sprintf('http://www.tianyayidu.cc/article-a-%d-%%d.html', id) |
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
require 'base64' | |
binary = File.open(File.join('.', 'img.jpg'), 'rb') do |io| | |
io.read | |
end | |
encoded = Base64.encode64(binary) | |
printf('<img src="data:image/jpeg;base64,%s"></img>', encoded) | |
# ruby encode_img.rb > img.html |
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
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>显示和隐藏</title> | |
<script type="text/javascript"> | |
function show(){ | |
document.getElementById('show').style.display = "block" | |
} | |
</script> | |
</head> |