Weather Monitor parsing bug
Started by HorusUK


Rate this topic
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5


7 posts in this topic
HorusUK
Senior Member
****


0
458 posts 40 threads Joined: Dec 2003
03-06-2004, 09:40 AM -
#1
In the following code fragment from a provider file I'm writing, I've found a potential problem with fetching temperatures.

Code:
; Dewpoint
; -------------------------------------------------------------------------
[CustomParam4]
name = Dewpoint
unit = C
find0 = "<!-- CURRENT REPORT TABLE -->"
find1 = "<!--Temp-->"
find2 = "Dewpoint:"
delim = "<"

Here's the HTML I'm parsing:
Code:
Dewpoint: 3 &deg;C<br />

Parsing this returns 0°C, but if I remove the Unit = C line from the provider file, I get 3 returned.

I've tried a delim = "&deg" just in case that was the cause, but I still get 0°C!
Yuri Kobets
Posting Freak
*****


10
6,208 posts 429 threads Joined: Jan 2002
03-06-2004, 12:46 PM -
#2
Try to change find2 string:
find2 = "Dewpoint: "
Add space into string.
The TORDEX Team
http://www.tordex.com
shapeshifter
Senior Member
****


0
658 posts 24 threads Joined: Sep 2002
03-06-2004, 06:14 PM -
#3
I'm pretty sure Yuri's suggestion will fix this problem, but just in case, you can try adding a "ValueType = INT" to your ini section. I'm not holding my breath on that one becuase I suspect that assigning C or F as the unit has the same effect. I do know that if you try to assign a string variable (like a space or a letter) to an INTeger variable type (such as with unit type C), the plugin will return a 0 as the measurement. (I'm pretty sure you already knew this, HorusUK, just posting it here for the benefit of others.) I exploited this in my X-Mod Wind skin. The web page I'm parsing will sometimes report "N/A" for the wind gust speed, which would throw off my skin's alignment. By telling WM to expect an INT(eger), it interprets "N/A" as 0, which fits just fine in my skin.
HorusUK
Senior Member
****


0
458 posts 40 threads Joined: Dec 2003
03-07-2004, 03:01 AM -
#4
Quote:...you can try adding a "ValueType = INT" to your ini section....
Shapeshifter, you're right, I've pretty pretty much exhausted all combinations here! The trouble with using a valuetype=int is that I can't get accurate °F temperatures as they're in the format 43.2°F, so valuetype=INT only returns 43°F. I too use the valuetype = INT "trick" to return 0 for gusts in my wind skin!

Quote:Try to change find2 string:
find2 = "Dewpoint: "
Add space into string.
Yuri, I changed my code to include spaces at the end of find2 = "Dewpoint " and beginning of "delim = " &deg" to eliminate ALL spaces:

Code:
; Dewpoint
; -------------------------------------------------------------------------
[CustomParam4]
name = Dewpoint
unit = C
find0 = "<!-- CURRENT REPORT TABLE -->"
find1 = "<!--Temp-->"
find2 = "Dewpoint: "
delim = " &deg"
and I *finally* get the correct temperature returned. Shouldn't white space be ignored when parsed if the valuetype isn't STRING?

Which brings me very nicely around to the point I made in this thread. Big Grin
shapeshifter
Senior Member
****


0
658 posts 24 threads Joined: Sep 2002
03-07-2004, 03:34 PM -
#5
Unless you specify a ValueType, the default is STRING. I think ignoring whitespace would cause problems. I frequently use a space as either a find parameter or a delimiter.

Yuri: I was under the assumption (though I'm not sure why) that WM only used one character as the delimiter. Is it true that you can use multiple characters to deliminate?
HorusUK
Senior Member
****


0
458 posts 40 threads Joined: Dec 2003
03-07-2004, 03:55 PM -
#6
shapeshifter Wrote:Unless you specify a ValueType, the default is STRING. I think ignoring whitespace would cause problems. I frequently use a space as either a find parameter or a delimiter.
That's the problem, shapeshifter, we all have slightly different requirements. And I must admit, I use a space as a delimiter, on occasion. Wink

Boy, has Yuri got his work cut out on the Universal Data Fetcher Big Grin
HorusUK
Senior Member
****


0
458 posts 40 threads Joined: Dec 2003
03-26-2004, 09:32 AM -
#7
Whilst parsing a news web site, I noticed that TLB is filtering out apostrophes. I'm not sure if other punctuation is affected.

i.e. I want to fetch Major Backs Blair's Libya Trip becomes Major Backs Blair s Libya Trip (notice the missing apostrophe in Blair s... Sad
Back once again...


Forum Jump:


Users browsing this thread: 1 Guest(s)