|
|
|
Помагите прочитать скрипт.
|
|||
|---|---|---|---|
|
#18+
' Feeds the Scala Text Crawl from VBScript. ' ' $Id: WindowsScriptCrawl.vbs,v 1.2 2003/05/15 20:37:44 peter Exp $ ' ' Parsing data off the web is generally easy if it is served ' up in XML. If the XML is well defined and well formed, ' you can expect the parsing script to remain valid over time. ' ' However, if you have to parse HTML, the mechanics can be ' quite a bit more involved, plus your scripts can break ' if the web site makes even modest changes to its format. ' ' --------------------------------------------------------------------------- ' ' Several useful functions for easier interfacing with Scala Text Crawl ' Wait until the Scala Text Crawl is ready for new text data Function Crawl_WaitReady() ' Poll 20 times per second until ready While ( control <> 1 ) oScala.Sleep( 50 ) Wend End Function ' Signal to the Scala Text Crawl that new text data is ready Function Crawl_SignalTextPosted() control = 0 End Function ' Signal to the Scala Text Crawl that there is no more data coming Function Crawl_SignalEndOfData() control = 2 End Function ' Wait for the Scala Text Crawl to be ready for new text, ' then post new text and signal. Function Crawl_PostText(sSegmentText) Crawl_WaitReady() CrawlText = sSegmentText Crawl_SignalTextPosted() End Function ' --------------------------------------------------------------------------- ' ' In this example, all the text to crawl is canned. But using VBScript, ' you can read your data from a file, from the web, in XML, whatever. ' (Arrays are just used here for convenience -- ultimately you just ' need to get your text into the crawl.) Dim Cities(3) Dim WeatherData(3, 5) Cities(1) = "Philadelphia, PA" WeatherData(1,1) = "This afternoon: Mostly cloudy. Chance of showers late in the day. Highs in the upper 60s. East winds 10 to 20 mph. Chance of rain 50 percent." WeatherData(1,2) = "Tonight: Occasional rain. Heavy at times after midnight. Lows in the lower 50s. East winds 10 to 20 mph. Chance of rain 90 percent." WeatherData(1,3) = "Friday: Occasional rain. Heavy at times. Windy and cooler. With highs in the upper 50s. Northeast winds 15 to 25 mph. Chance of rain 90 percent." WeatherData(1,4) = "Friday night: Showers likely. Lows near 50. Chance of rain 60 percent." WeatherData(1,5) = "Saturday: Partly sunny with a chance of showers. Highs in the upper 50s. Chance of rain 30 percent." Cities(2) = "Chicago, IL" WeatherData(2,1) = "This afternoon: Mostly cloudy with a chance of showers. High from the lower 50s along the lake to around 60 well inland. Northeast winds 10 to 15 mph. Chance of rain 30 percent." WeatherData(2,2) = "Tonight: Becoming partly cloudy. Low in the mid 40s. Northeast winds 10 to 15 mph becoming light north." WeatherData(2,3) = "Friday: Partly cloudy. High ranging from near 60 along the lake to the mid 60s inland. Northeast winds 5 to 10 mph." WeatherData(2,4) = "Friday night: Partly cloudy. Low in the upper 40s." WeatherData(2,5) = "Saturday: Partly cloudy. High from the lower 60s lakeside to the upper 60s inland." Cities(3) = "San Francisco , CA" WeatherData(3,1) = "Today: Mostly cloudy with patchy fog in the morning. Mostly sunny and locally breezy in the afternoon. Highs from the mid 60s near the bay to the mid 70s well inland. West afternoon winds 15 to 25 mph." WeatherData(3,2) = "Tonight: Mostly clear. Lows from the mid 40s to lower 50s. West evening winds 15 to 25 mph." WeatherData(3,3) = "Friday: Partly cloudy. Highs from the upper 60s near the bay to near 80 well inland. Northwest afternoon winds 15 to 25 mph." WeatherData(3,4) = "Friday night: Partly cloudy. Lows from the mid 40s to lower 50s." WeatherData(3,5) = "Saturday: Mostly sunny. Highs from the upper 60s to near 80." ' --------------------------------------------------------------------------- ' ' Instantiate the Scala interface Dim oScala Set oScala = CreateObject("ScalaPlayer.ScalaPlayer.1") ' --------------------------------------------------------------------------- ' ' Loop forever While True ' --------------------------------------------------------------------------- ' ' Process each city For nCity = 1 To 3 ' --------------------------------------------------------------------------- ' ' Use RomanaTMed for the city banner ' Crawl_PostText("<typeface=""RomanaTMed (Western [])""> <typesize=""35"">") ' For each city, crawl the message "*** Weather for City ***": Crawl_PostText("<facecolor=""#ff4444"">••• Weather for " & Cities(nCity) & " •••") ' Set the font to Arial for the rest of the information ' Crawl_PostText("<typeface=""Arial (Western [])""> <typesize=""35"">") bFirstWeather = True ' --------------------------------------------------------------------------- ' ' Process each forecast of the current city For nForecast = 1 To 5 forecast = WeatherData(nCity, nForecast) ' Split the forecast into the "when" part and the "details" part ' so we can format each separately. p = InStr(forecast, ":") If (p > 0) Then sWhen = Left(forecast, p) sDetails = Mid(forecast, p+1) Else sWhen = "" sDetails = forecast End If ' --------------------------------------------------------------------------- ' ' Crawl the "***" separator in red If (bFirstWeather) Then ' Don't need one before the first weather forecast of each city bFirstWeather = False Else Crawl_PostText("<facecolor=""#ff4444"">•••") End If ' --------------------------------------------------------------------------- ' ' Crawl the weather "when" information (e.g. "Thursday night:") in yellow Crawl_PostText("<facecolor=""#ffee44"">" & sWhen) ' --------------------------------------------------------------------------- ' ' Crawl the weather details (e.g. "Cloudy with a chance of snow") in white Crawl_PostText("<facecolor=""#ffffff"">" & sDetails) Next ' nForecast Next ' nCity Wend О чем этот скрипт?? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.01.2008, 17:37 |
|
||
|
|

start [/forum/topic.php?fid=22&fpage=348&tid=1457025]: |
0ms |
get settings: |
6ms |
get forum list: |
18ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
45ms |
get topic data: |
11ms |
get forum data: |
2ms |
get page messages: |
45ms |
get tp. blocked users: |
2ms |
| others: | 237ms |
| total: | 372ms |

| 0 / 0 |
