Class: Actir::CookiesBaidu
- Inherits:
-
Object
- Object
- Actir::CookiesBaidu
- Defined in:
- lib/actir/script/cookies_baidu.rb
Class Method Summary collapse
-
.clear_after_failure ⇒ Object
更新baidu_cookies失败后的清理操作。目前需要手动调用,后续优化.
-
.get_useful_card ⇒ Object
获取可用的百度账号的hash 返回值=> {“username” => “xxx”, “password”=>“iloveyouzan”, xxx}.
-
.re_available ⇒ Object
将所有百度支付卡的available状态恢复为true.
-
.set_useless_card(card) ⇒ Object
设置不可用的卡 入参传入卡的key.
-
.update_all(address = []) ⇒ Object
更新百度账号所有的配置文件.
Class Method Details
.clear_after_failure ⇒ Object
更新baidu_cookies失败后的清理操作。目前需要手动调用,后续优化
63 64 65 66 67 |
# File 'lib/actir/script/cookies_baidu.rb', line 63 def clear_after_failure if @browser != nil @browser.close end end |
.get_useful_card ⇒ Object
获取可用的百度账号的hash 返回值=> {“username” => “xxx”, “password”=>“iloveyouzan”, xxx}
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/actir/script/cookies_baidu.rb', line 39 def get_useful_card # old_config = Actir::Config.config_dir # Actir::Config.config_dir = script_config_path #通过配置文件判断取出可用的卡的参数 baidu_card = Actir::Config.get("cookies.baidu") card = {} baidu_card.each do |key, value| if value["available"] == true #有可用的卡,取出cookies等参数 card.store(key, value) break end end # Actir::Config.config_dir = old_config card end |
.re_available ⇒ Object
将所有百度支付卡的available状态恢复为true
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/actir/script/cookies_baidu.rb', line 17 def re_available #每次登陆都判断一下cookies文件的上一次修改时间和当前时间 #如果日期不同,则刷新所有的cookies文件中baidu-card的状态 unless Actir::Config.is_same_day?("cookies") Actir::Config.lock("cookies") do str_array = IO.readlines() str_array.each_with_index do |line, index| if line =~ /available\:\s*false/ str_array[index] = line.gsub(/false/, 'true') end end = File.open(, 'w') str_array.each do |line| .puts line end .close end end end |
.set_useless_card(card) ⇒ Object
设置不可用的卡入参传入卡的key
58 59 60 |
# File 'lib/actir/script/cookies_baidu.rb', line 58 def set_useless_card(card) Actir::Config.set("cookies.baidu." + card + "." + "available", "false") end |
.update_all(address = []) ⇒ Object
更新百度账号所有的配置文件
9 10 11 12 13 14 |
# File 'lib/actir/script/cookies_baidu.rb', line 9 def update_all(address = []) baidu_card = Actir::Config.get("cookies.baidu") baidu_card.each do |card, value| (card, address) end end |