施工完毕
require 'net/http'
uri = URI.parse ("
http://www.icbc.com.cn/ICBCDynamicSite2/other/rmbdeposit.aspx")
html = Net::HTTP.get uri
dates = []
html.scan (/<option value="(\d{4}-\d{2}-\d{2})">/) {|s| dates += s }
html =~ /name="__VIEWSTATE" id="__VIEWSTATE" value="(.*)" \/>/
params = {
'__EVENTTARGET' => 'Sel_Date',
'__EVENTARGUMENT' => '',
'__LASTFOCUS' => '',
'__VIEWSTATE' => $1.clone
}
dates.each do |date|
params['Sel_Date'] = date
res = Net::HTTP.post_form uri, params
# 正则提取具体内容就不写了,这里直接输出 html =_=b
open ("#{date}.html", 'w') {|io| io.write res.body }
end