Reply to comment

strict warning: Only variables should be passed by reference in /var/www/www.waterworld.com.hk/sites/all/modules/captcha/captcha.inc on line 61.

iPhone 5 抽獎自動化

身在香港,現時如果想買部 iPhone 5 玩下,一是上台出機,一是到以下網站抽獎:

https://reserve.apple.com/HK/en_HK/reserve/iPhone

但是日日抽太辛苦,於是自己寫了 script 作 automation,方法一是用 web browser 的 automation extension,但身為programmer 我比較喜歡可以一個command line 就做完所有事。於是我用第二個方法,用 headless browser,所謂 headless browser 即是是沒有 ui 我 browser,一般比較流行的是 Mechanize

http://mechanize.rubyforge.org/

但考慮到自己 ruby 戰鬥力比較差,於是用了 phantomjs

http://phantomjs.org

phantomjs 比 mehanize 更好的是,它是內置 webkit,所以他是可以隨時 render screen capture,用來 debug 非常方便。

首先一定要 install phantomjs,http://phantomjs.org/download.html 。因為我用 mac,只要用 homebrew 便可以 install 到,非常方便。如果不知 homebrew 是什麼請參考 http://mxcl.github.com/homebrew/

這是我寫的 script,非常簡單:

https://gist.github.com/3950082

要使用只要在 command line 打:

phantomjs iphonereserve.coffee "Tai Man" "Chan" "taiman@gmail.com" "A12345678" "MD299ZP/A" "R485"

十分方便吧,最後兩個param是model code 和 store code,可以在 source code 最頭找到相對意思。如果想一次過買多次六合彩,可以寫一個shell script…


#!/bin/bash
date
phantomjs iphonereserve.coffee "Tai Man" "Chan" "taiman@gmail.com" "A12345678" "MD297ZP/A" "R485"
phantomjs iphonereserve.coffee "Tai Man" "Chan" "taiman@gmail.com" "A12345678" "MD298ZP/A" "R485"
phantomjs iphonereserve.coffee "Tai Man" "Chan" "taiman@gmail.com" "A12345678" "MD299ZP/A" "R485"

最後,用此方法我暫時還是一次也沒有抽到的,所以後果自負。

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
11 + 8 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.