I'm using webpaser in my skin and it works great but sometimes the website from which the data is taken is not updated on time and that causes the skin to have no output at all.
I was just wondering if there is a way to show a message like "Data not available" instead of it being blank.
Sometimes the website has 2/5 information that I want [stringindex 1 & 2 have data but 3,4,5 don't] but again since all the data is not present it doesn't show anything. How can I show the data that is present and show "data not available" for the rest?
It is currently April 19th, 2024, 2:36 am
How to Show a Custom Error Message
-
- Posts: 16
- Joined: March 30th, 2018, 12:33 am
-
- Rainmeter Sage
- Posts: 16144
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: How to Show a Custom Error Message
Maybe using the Lookahead Assertions could help, but not knowing the URL you're talking about, probably no one can help. So, please post the code you have so far.
-
- Posts: 16
- Joined: March 30th, 2018, 12:33 am
Re: How to Show a Custom Error Message
It gets info from "Next Launch" on http://www.spaceflightinsider.com/launch-schedule/
Sometimes only half of the info is available e.g Mission Name, Date, etc. but others like location are missing. What is the best way to deal with a scenario like that when webparser doesn't get all the information.
Should I have separate webparser for each?
Sometimes only half of the info is available e.g Mission Name, Date, etc. but others like location are missing. What is the best way to deal with a scenario like that when webparser doesn't get all the information.
Should I have separate webparser for each?
Code: Select all
[MeasureSite]
Measure=Plugin
Plugin=WebParser
URL=http://www.spaceflightinsider.com/launch-schedule/
RegExp=(?siU)<div class="cd_img".*'(.*)'.*src="(.*)".*<div class="cd_info".*"mission".*">(.*)</a></td>.*"provider">.*<img src="(.*)".*title="(.*)".*<th>Vehicle</th>.*<td class="vehicle">(.*)</td>.*<th>Time</th>.*<td>(.*) (.*) (.*):(.*):(.*) (.*)</td>.*<td>(.*)</td>
UpdateRate=3600
FinishAction=[!EnableMeasureGroup Countdown][!ShowMeterGroup Countdown]
;-------------------------------
[Measure_Operator_Logo]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1
Download=1
[Measure_Vechicle_Img]
Measure=WebParser
URL=[MeasureSite]
StringIndex=2
Download=1
[Measure_Mission]
Measure=WebParser
URL=[MeasureSite]
StringIndex=3
[Measure_LSP_Logo]
Measure=WebParser
URL=[MeasureSite]
StringIndex=4
Download=1
[Measure_LSP]
Measure=WebParser
URL=[MeasureSite]
StringIndex=5
[Measure_Vehicle]
Measure=WebParser
URL=[MeasureSite]
StringIndex=6
[Measure_Day]
Measure=WebParser
URL=[MeasureSite]
StringIndex=7
[Measure_Month]
Measure=WebParser
URL=[MeasureSite]
StringIndex=8
[Measure_Hour]
Measure=WebParser
URL=[MeasureSite]
StringIndex=9
[Measure_Minute]
Measure=WebParser
URL=[MeasureSite]
StringIndex=10
[Measure_Second]
Measure=WebParser
URL=[MeasureSite]
StringIndex=11
[Measure_TimeZone]
Measure=WebParser
URL=[MeasureSite]
StringIndex=12
[Measure_Location]
Measure=WebParser
URL=[MeasureSite]
StringIndex=13
-
- Rainmeter Sage
- Posts: 16144
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: How to Show a Custom Error Message
This is a possibility, but probably not the best one. You should have to read the whole expression by one. Using the Lookahead Assertions, the WebParser measures which find the appropriate strings would return those, while the others would return empty strings.Krishneel Chand wrote:Sometimes only half of the info is available e.g Mission Name, Date, etc. but others like location are missing. What is the best way to deal with a scenario like that when webparser doesn't get all the information.
Should I have separate webparser for each?
To use the Lookahead Assertions you have to rewrite the RegExp option of the parent WebParser measure (in this case this is the [MeasureSite] measure. Try the following RegExp:
Code: Select all
[MeasureSite]
...
RegExp=(?siU)<div class="cd_img".*'(.*)'.*src="(.*)".*<div class="cd_info".*(?(?=.*"mission).*".*<a href=".*">(.*)</a></td>).*"provider">(?(?=.*<img src).*="(.*)").*(?(?=.*title).*="(.*)")(?(?=.*<th>Vehicle).*</th>.*<td class="vehicle">(.*)</td>)(?(?=.*<th>Time).*</th>.*<td>(.*) (.*) (.*):(.*):(.*) (.*)</td>).*(?(?=.*<tr>).*<th>Location</th>.*<td>(.*)</td>)
Unfortunately I'm not sure at all the above RegExp is working well in all conditions. Depending on what part of the website code is missing, there could be (or even better, probably will be) cases when the measure won't work properly. The RegExp must be refined, when different situations come out. However the above expression can be a start.