It is currently April 16th, 2024, 8:03 am

Web Parser not downloading all data (sometimes)

Get help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 16141
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Web Parser not downloading all data (sometimes)

Post by balala »

xenium wrote:Posting code for a location that does not work ? It's very, very, very big ...
I post the link http://aqicn.org/city/seoul/
This is even better.
In such cases (when there are some info which either can be there or can miss), the Lookahead Assertion can make a good service. This feature is used when you can't be sure if some parts of the website are or are not there.
To use it, try the following RegExp (in my rewritten code):

Code: Select all

[MeasureN]
...
RegExp=(?siU)<a href='http://aqicn.org/city/(.*)/.*'.*(?(?=.*<td id='cur_t').*class='tdcur' style='.*' align=center><span class='temp' format='nu' temp=.*>(.*)</span></td>.*<td id='min_t' class='tdmin' style='.*' align=center><span class='temp' format='nu' temp=.*>(.*)</span></td>.*<td id='max_t' class='tdmax' style='.*' align=center><span class='temp' format='nu' temp=.*>(.*)</span></td>).*(?(?=.*<td id='cur_d').*class='tdcur' style='.*;' align=center><span class='temp' format='nu' temp=.*>(.*)</span></td>.*<td id='min_d' class='tdmin' style='.*' align=center><span class='temp' format='nu' temp=.*>(.*)</span></td>.*<td id='max_d' class='tdmax' style='.*' align=center><span class='temp' format='nu' temp=.*>(.*)</span></td>).*(?(?=.*<td id='cur_p').*class='tdcur' style='.*' align=center>(.*)</td>.*<td id='min_p' class='tdmin' style='.*' align=center>(.*)</td>.*<td id='max_p' class='tdmax' style='.*' align=center>(.*)</td>).*(?(?=.*<td id='cur_h').*class='tdcur' style='.*' align=center>(.*)</td>.*<td id='min_h' class='tdmin' style='.*' align=center>(.*)</td>.*<td id='max_h' class='tdmax' style='.*' align=center>(.*)</td>)
See the (?)?= parts of the above RegExp. These are used to check if the immediately following string (up to the first closed parentheses) exists or doesn't. If it is, the appropriate strings are returned by the appropriate measures, otherwise these measures return empty strings.
In my tries, the above RegExp works for both, Beijing and Seoul. Does it for you, too?
User avatar
xenium
Posts: 857
Joined: January 4th, 2018, 9:52 pm

Re: Web Parser not downloading all data (sometimes)

Post by xenium »

balala wrote:This is even better.
In such cases (when there are some info which either can be there or can miss), the Lookahead Assertion can make a good service. This feature is used when you can't be sure if some parts of the website are or are not there.
To use it, try the following RegExp (in my rewritten code):

Code: Select all

[MeasureN]
...
RegExp=(?siU)<a href='http://aqicn.org/city/(.*)/.*'.*(?(?=.*<td id='cur_t').*class='tdcur' style='.*' align=center><span class='temp' format='nu' temp=.*>(.*)</span></td>.*<td id='min_t' class='tdmin' style='.*' align=center><span class='temp' format='nu' temp=.*>(.*)</span></td>.*<td id='max_t' class='tdmax' style='.*' align=center><span class='temp' format='nu' temp=.*>(.*)</span></td>).*(?(?=.*<td id='cur_d').*class='tdcur' style='.*;' align=center><span class='temp' format='nu' temp=.*>(.*)</span></td>.*<td id='min_d' class='tdmin' style='.*' align=center><span class='temp' format='nu' temp=.*>(.*)</span></td>.*<td id='max_d' class='tdmax' style='.*' align=center><span class='temp' format='nu' temp=.*>(.*)</span></td>).*(?(?=.*<td id='cur_p').*class='tdcur' style='.*' align=center>(.*)</td>.*<td id='min_p' class='tdmin' style='.*' align=center>(.*)</td>.*<td id='max_p' class='tdmax' style='.*' align=center>(.*)</td>).*(?(?=.*<td id='cur_h').*class='tdcur' style='.*' align=center>(.*)</td>.*<td id='min_h' class='tdmin' style='.*' align=center>(.*)</td>.*<td id='max_h' class='tdmax' style='.*' align=center>(.*)</td>)
See the (?)?= parts of the above RegExp. These are used to check if the immediately following string (up to the first closed parentheses) exists or doesn't. If it is, the appropriate strings are returned by the appropriate measures, otherwise these measures return empty strings.
In my tries, the above RegExp works for both, Beijing and Seoul. Does it for you, too?
It works! Thank you very much
I tried several locations and it works!
I hope this website does not reserve any other issues.
I will use (?)?=, when I fill in the code with the rest of the data
The above RegExp, works along with ?:
balala wrote:My solution work ONLY if those String meters which aren't displayed (or in fact they are empty), are hidden and only those are shown, which have a value to show up. So, in the Testdynamictext.ini skin, the second String meter ([MeterDewpoint], which should have to show up the value returned by the [MeasureDewpoint] measure) should have to be hidden, while the other two, should have to remain visible. In the Testdynamictext2.ini, [MeterHumidity] should have to remain visible and [MeterFeelsLike] and [MeterDewpoint] should have to be hidden.
To achieve this, you should have to add some IfMatch options to the [MeasureFeelsLike], [MeasureDewpoint] and [MeasureHumidity] measures, in both files:

Code: Select all

[MeasureFeelsLike]
...
IfMatch=^$
IfMatchAction=[!HideMeter "MeterFeelsLike"]
IfNotMatchAction=[!ShowMeter "MeterFeelsLike"]

[MeasureDewpoint]
...
IfMatch=^$
IfMatchAction=[!HideMeter "MeterDewpoint"]
IfNotMatchAction=[!ShowMeter "MeterDewpoint"]

[MeasureHumidity]
...
IfMatch=^$
IfMatchAction=[!HideMeter "MeterHumidity"]
IfNotMatchAction=[!ShowMeter "MeterHumidity"]
Take care to just add the above options, don't remove the existing ones.
These options will hide the empty strings.
User avatar
balala
Rainmeter Sage
Posts: 16141
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Web Parser not downloading all data (sometimes)

Post by balala »

xenium wrote:The above RegExp, works along with ?:
To be honest I can't remember exactly where did we use those IfMatch options (and I'm lazy to go through the whole thread, to find it), but probably it will. Give it a try.
I'm glad if you got it working.