1 Require ' Nokogiri '
2 Require ' Open-Uri '
3 Require " Iconv "
4
5 Task: dreamtype => : Environment Do
6 # Doc = Nokogiri: HTML (file. Open ( " A.html " ))
7 # Doc.css ( " Table.txt> tr> TD: Nth-Child (1) " ). Each Do | Link |
8 # Dream. Create (: URL => " A " ,: Name => Link. Content)
9 # End
10 # Da = Iconv. iconv ( " UTF-8 " , " Gb2312 " , Nokogiri: HTML (open (URL )))
11 IC = Iconv. New ( " UTF-8 /// ignore " , " Gb2312 // ignore " )
12 Doc = Nokogiri: HTML (file. Open ( " A.html " ))
13 Doc.css ( " Table.txt> TR: Nth-child (8)> TD: Nth-child (2)> " ). Each Do | K |
14 URL = " Http://www.tongcha.com/ " + K [: href]
15 Da = Nokogiri: HTML (open (URL ))
16 Da.css ( " Table.txt> TR: Nth-Child (1)> TD " ). Each Do | C |
17 # Puts C. Content
18 Daydream. Create (: dream_id => 8 ,: Name => K. Content,: Content => C. Content)
19 End
20 Puts URL
21 End
22 End