module BBwin
$time=0
def self.获取指定网页源代码 #
#a = url_data("https://price.btcfans.com/") #网页例子
a = url_data("http://i.tianqi.com/index.php?c=code&id=64")
f = File.open("网页源代码.txt","w+")
#f = File.open("网页源代码.txt","w+") #a+意思:讀取,写入,覆盖原文件,文件不存在自动创建
#$a = $a#.to_s
f.write(a) #VX ACE版本要变成变量才行不能单独使用
f.close
end #def
def self.获取近五天的天气 #
#f = File.open("网页源代码.txt","w+")
@第几天 = 0
@第几天文字 = ""
@周几 = ""
$subject=[]
$subject = File.readlines("网页源代码.txt")#$subject等于行里所有行数
#p $subject.size
for i in 0...$subject.size #遍历所有行数
$subject[i].chomp! #!發生變化并返回
#$subject[i] =~ /比特币价格<(\d+)/i #错误示范
#p $subject[i]
$subject[i] =~ /<div class="date">/#匹配文本中的data-usd="后的数字
if $~ !=nil
#p $~[1]#匹配全部匹配到的的一个变量为$1
#p $subject[i]
end #if
if $subject[i].include?("周一")
@周几 = "周一"
elsif $subject[i].include?("周二")
@周几 = "周二"
elsif $subject[i].include?("周三")
@周几 = "周三"
elsif $subject[i].include?("周四")
@周几 = "周四"
elsif $subject[i].include?("周五")
@周几 = "周五"
elsif $subject[i].include?("周六")
@周几 = "周六"
elsif $subject[i].include?("周日")
@周几 = "周日"
end #if
$subject[i] =~ /近6天天气预报/
if $~ !=nil
a = $subject[i]
b = a.sub!(/ .*?">/, "")
c = b.sub!(/<.*?\/a>/, "")
c1 = c
# p c
end #if
$subject[i] =~ /<p class="degrees">/
if $~ !=nil
#第几天
if @第几天 == 0
@第几天文字 = "第一天(今天)"
elsif @第几天 == 1
@第几天文字 = "第二天(明天)"
elsif @第几天 == 2
@第几天文字 = "第三天"
elsif @第几天 == 3
@第几天文字 = "第四天"
elsif @第几天 == 4
@第几天文字 = "第五天"
elsif @第几天 == 5
@第几天文字 = "第六天"
end #if
@第几天 += 1
a = $subject[i]
#b = a.sub!(/">.*$/, "")
#b = a.sub!(/">.*?<s/, "")
# b = a.sub!(/">.*?<s/, "")
b = a.sub!(/ .*?">/, "")
c = b.sub!(/<sup>.*?<\/p>/, "")
c2 = c
#p c
end #if
$subject[i] =~ /<p class="climate">/
if $~ !=nil
a = $subject[i]
b = a.sub!(/ .*?">/, "")
c = b.sub!(/<.*?\/p>/, "")
#p c
c3 = c
p c1,@第几天文字,c2,c3
end #if
end #for i
end #def
end #module