惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
CERT Recently Published Vulnerability Notes
V
Vulnerabilities – Threatpost
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
Schneier on Security
Schneier on Security
T
Threatpost
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
大猫的无限游戏
大猫的无限游戏
T
Threat Research - Cisco Blogs
罗磊的独立博客
Security Latest
Security Latest
D
Docker
S
Secure Thoughts
博客园 - 聂微东
A
Arctic Wolf
Recorded Future
Recorded Future
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
P
Palo Alto Networks Blog
Project Zero
Project Zero
Blog — PlanetScale
Blog — PlanetScale
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Help Net Security
T
The Blog of Author Tim Ferriss
Latest news
Latest news
AWS News Blog
AWS News Blog
U
Unit 42
Stack Overflow Blog
Stack Overflow Blog
The GitHub Blog
The GitHub Blog
Know Your Adversary
Know Your Adversary
Vercel News
Vercel News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
F
Full Disclosure
Martin Fowler
Martin Fowler
T
The Exploit Database - CXSecurity.com
Attack and Defense Labs
Attack and Defense Labs
Y
Y Combinator Blog
Microsoft Security Blog
Microsoft Security Blog
V
V2EX
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
小众软件
小众软件
宝玉的分享
宝玉的分享

博客园 - 阿武

Moto G 通话没声音 Android 手机技巧 一个Java程序的生死旅程 精妙语录 【Windows Phone 7】【软件发布】深圳通助手 & 深圳长途汽车查询 & 深圳地铁通 [C++ Primer] Passing an array to a function by reference/pointers -- sample 【Ruby】删除旧文件 64位的处理器支持多大的内存? 将.NET Entity Framework 的 Cache模块移植到JAVA平台 做快乐的程序员 Q 语言初学者系列:(3)Lists 初级 KDB+性能分析:内存篇 Q 语言初学者系列:(2)基本数据类型 Q 语言初学者系列:(1)开门篇 熟悉的感觉 盘点自己两年来走过的路 [JAVA]你见过这样的switch吗? - 阿武 - 博客园 网站上图片"另存为" 为什么是 bmp 格式 经实验, 网线两端都接在交换机上并不会烧毁交换机
京东自动抢购机
阿武 · 2011-06-20 · via 博客园 - 阿武

京东抢购页面: http://qiang.360buy.com/LimitBuy.htm

有效时间:2011.6.1 - 2011.6.30 

开发语言:Ruby 

运行环境:Ruby 1.9.2 (需要安装 watir)

文件名:qiang.rb

运行命令:ruby qiang.rb 

说明:可以自动抢购商品,并自动进入购物车结算,结算过程可能会遇到需要验证码情况,结算将会失败,需要手动干预。 

require 'logger'
require 
'watir'

STDOUT.sync 

= true
log = Logger.new(STDOUT)
log.level = Logger::DEBUG

$host 

= 'qiang.360buy.com'

auto_goto_shopping_cart         

= true
    auto_goto_orderinfo         
= false # depends on the previous parameter
        auto_submit_order         
= false # depends on the previous parameter

url 

= "http://#{$host}/LimitBuy.htm"
ie 
= Watir::IE.new
ie.
goto url
error_times 
= 0
first 
= true
while true do
    
begin
        ie.refresh unless first
        ie.wait
        
        first 
= false
        error_times 
= 0
    rescue StandardError 
=> bang
        
log.error "Error: #{bang}"
        
        error_times 
+= 1
        
break if error_times > 10 
        
        redo
    
end    
    
begin
        li 
= ie.li(:xpath, "//li[@class='fore rob'][2]")
        
        unless li.
exists?
            
log.info 'Checking...'
            redo
        
end
        
        # OK, QIANG NOW

        target 

= li.links[1].href
        
log.info target
        
        
if auto_goto_orderinfo
            li.links
[1].click
        
else
            li.links
[1].click_no_wait
        
endlog.info '-> Going to the InitCart page...'        
        
        
log.info '########################################################################################'    
        
        
begin
            
            #ie2 
= Watir::IE.attach(:title, '商品已成功加入购物车'.encode!('gbk'))
            ie2 
= Watir::IE.attach(:url, target)
            
if ie2.nil?
                
log.warn 'ie2 is null.'
            
else
                
if auto_goto_shopping_cart
                    ie2.link(:id, 
'GotoShoppingCart').click 
                    
log.info '-> going to the shopping cart page...'
                    
                    
if auto_goto_orderinfo                        
                        ie3 
= Watir::IE.attach(:url, "http://jd2008.360buy.com/purchase/shoppingcart_pop.aspx?backurl=http://#{$host}/LimitBuy.htm")            
                        ie3.link(:id, 
'gotoOrderInfo').click
                        
log.info '-> going to the order confirm page...'
                        
                        
if auto_submit_order
                            ie4 
= Watir::IE.attach(:url, 'http://jd2008.360buy.com/purchase/orderinfo_pop_main.aspx')
                            
if ie4.image(:id, 'OrderCheckCodeImg').exists?
                                
log.info 'No way!!! need validation code to submit the order.'
                            
else                            
                                ie4.button(:id, 
'submit').click
                                
log.info 'Order is submited.'
                            
end
                        
end
                    
end
                
end
            
end
        rescue StandardError 
=> bang
            
log.error "Error: #{bang}"
        
end
        
        
log.info '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
        
        
break
    rescue StandardError 
=> bang
        
log.error "Error: #{bang}"
    
end

end