Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 0.96 KB | None | 0 0
  1. bind pub - !тест parsing
  2.  
  3. proc parsing {nick uhost hand chan text} {    
  4. ::http::config -useragent "Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)"
  5. set parsing_tok [::http::geturl "http://m.gismeteo.ru/weather/4392/current/" -timeout 20000]
  6. set data [regsub -all -- {\n|\r|\t|\v} [::http::data $parsing_tok] ""]
  7. ::http::cleanup $parsing_tok
  8. if {[regexp -nocase -- {<div class="menu__item bold">(.*?)</div>} $data -> region]} {  
  9. regsub -all -- {<.*?>} $region {} region
  10. regsub -all -- {&nbsp;/} $region {} region
  11. set strana [lindex $region 0]  
  12. set gorod [lindex $region 1]
  13. regexp -nocase -- {<div class="title">(.*?)</div>} $data -> sdata
  14. regexp -nocase -- {<td class="weather__temp"><span>(.*?)</span></td>} $data -> temp
  15.  
  16. putserv "PRIVMSG $chan : Страна: $strana; Город: $gorod Прогноз погоды на: $sdata; Температура воздуха: $temp"
  17.  
  18. } {putserv "NOTICE $nick :Ошибка парсинга."}
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement