Advertisement
htym

MeteoMaps_ru.vbs

Feb 21st, 2020
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Сделаем на всякий случай перезапуск в кодовой странице ОС из ДОС
  2. If  Lcase(Right(Wscript.FullName, 12)) =    "\cscript.exe" Then
  3.     CreateObject("Wscript.Shell").Run "wscript.exe " & Chr(34) & Wscript.ScriptFullName & Chr(34)
  4.     Wscript.Quit
  5. End If
  6. On Error Resume Next
  7. URL = "http://meteomaps.ru/meteostation_codes.html"
  8. Set IE  = CreateObject("InternetExplorer.Application")
  9. IE.Navigate URL
  10. While   IE.Busy Or (IE.ReadyState <> 4)     'ждём, пока страница загрузиться
  11. Wend    'DoEvents
  12. C   = IE.Document.body.innerHtml        'считываем HTML код веб-страницы в текстовую переменную
  13. IE.Quit
  14. Set IE  = Nothing
  15. 'Файл начинается с 3 символов [EF BB BF], которые превращают его в двоичный, поэтому просто вырезаем таблицу и получаем только текст для сохранения в файл
  16. Call    R2(C,"</table",0)(C,"<table ",1)    'вырезаем таблицу
  17. C   = "<table " & C & "</table"     'здесь восстанавливаем теговую структуру таблицы
  18. CreateObject("Scripting.FileSystemObject").CreateTextFile("f.htm",True).Write(C).Close 'сохраним таблицу в виде файла
  19. 'удаляем теги и спецсимволы, между столбцами вставляем разделитель |
  20. Call    R1(C,Chr(10),"")(C,Chr(13),"")(C,"</tr>","</tr>"&vbCrLf)(C,"<tr>  <td>","")(C,"</td>  <td>","|")(C,"</td> </tr>","")(C," </tr>"&vbCrLf,"")
  21. f   = "C.txt"   'файл для работы
  22. CreateObject("Scripting.FileSystemObject").CreateTextFile(f,True).Write(C).Close
  23. 'MsgBox "The End":Wscript.Quit          'Для отладки прерываем работу
  24. t1  = InputBox("Введите Ваш город","Город","Брянск")
  25. Set tsLog   = CreateObject("Scripting.FileSystemObject").OpenTextFile(f,1)
  26. Do While    Not tsLog.AtEndOfStream
  27.     LineInFile  = Trim(tsLog.ReadLine)
  28.     i1  = InStr(1,LineInFile,t1,1)
  29.     If  i1 <> 0 Then
  30.         out = out&LineInFile&vbCrLf
  31.         M   = Split(LineInFile,"|")
  32.         CreateObject("WScript.Shell").Run "https://www.meteonova.ru/weather/"&M(0'откроем страницу с погодой в данной точке по сайту meteonova.ru
  33.         CreateObject("WScript.Shell").Run "https://www.meteonova.ru/speech/forecast_"&M(0)&"_0.mp3" 'откроем страницу с погодой в данной точке по сайту meteonova.ru
  34.         WScript.Sleep   1000*1
  35.     End If
  36. Loop
  37. CreateObject("Scripting.FileSystemObject").OpenTextFile(f,2,true).WriteLine (out)
  38. 'CreateObject("WScript.Shell").Run "f.html"
  39. MsgBox "The End."
  40. Function R1 (Cc,x,y)
  41.     C     = Replace(Cc,x,y)
  42.     Set R1 = GetRef("R1")
  43. End Function
  44. Function R2 (Cc,x,y)
  45.     C     = Split(Cc,x)(y)
  46.     Set R2 = GetRef("R2")
  47. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement