it's working...
It is currently April 27th, 2024, 3:31 am
Generate Automatic WeatherCode from IP address in use
-
- Posts: 442
- Joined: July 30th, 2014, 10:30 am
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Generate Automatic WeatherCode from IP address in use
Thank you. Very good you've found this mistake of mine. Congratulations for your attention.
-
- Posts: 442
- Joined: July 30th, 2014, 10:30 am
Re: Generate Automatic WeatherCode from IP address in use
Ah, thanks God who gave me at least a bit of the brain to make use of it.
And what are all my helps compared to yours, morley's, eclectic's...
A seed of mustard in the ocean.
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Generate Automatic WeatherCode from IP address in use
Don't worry, every help is useful in its own way. On certain moment, the current help is the most important. This time for instance for me, yours.Pul53dr1v3r wrote: ↑October 4th, 2019, 8:54 pm And what are all my helps compared to yours, morley's, eclectic's...
-
- Developer
- Posts: 22631
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Generate Automatic WeatherCode from IP address in use
WebParser doesn't detect your browser of course. But when you access a remote site, that site can query your system for certain things. Most browsers are designed to answer these queries, but for the most part WebParser is not. What WebParser can do is provide a UserAgent string, which will tell the remote site that you are using some defined browser (which is a lie, you are using WebParser), and that can be useful on a site that for instance outputs something slightly different when accessed with Chrome vs. Microsoft IE.balala wrote: ↑October 4th, 2019, 8:21 pm Yeah, probably a better approach.
Can you reply to my last question here: https://forum.rainmeter.net/viewtopic.php?f=5&t=33606#p166268, please?
-
- Posts: 207
- Joined: October 4th, 2019, 2:46 pm
Re: Generate Automatic WeatherCode from IP address in use
Thanks, that did the trick.
So I just had to add the FinishAction command.
FinishAction=[!CommandMeasure MeasureWeatherCode "Update"]
1st Question:
Maybe stupid question, but WHY and why at this location?
2nd question:
Now I have the correct weatherCode I need to put it in the URL of below code.
Normally a variable " #WeatherCodeLocation# " is in this line but now I have a measure called " MeasureCode "
What would be the correct way to do this, !Setvariable, or...?
Code: Select all
[MeasureWeatherRSS] Measure=WebParser.dll UpdateRate=3600 Url=http://wxdata.weather.com/wxdata/weather/local/#WeatherCodeLocation#?cc=*&unit=#WeatherUnit#&dayf=6 ;http://wxdata.weather.com/wxdata/weather/local/NLXX0272?cc=*&unit=m&dayf=6 RegExp=(?siU)<weather ver="(.*)">(.*)<tmp>(.*)</tmp>(.*)<t>(.*)</t>(.*)<icon>(.*)</icon>(.*)<d>(.*)</d>.*<wind>.*<s>(.*)</s>.*<d>(.*)</d>
jsmorley wrote: ↑October 4th, 2019, 3:27 pm Something like this worked for me:
It's not the perfect location, not the one I use in my skin(s), but since it is based on the local "point of presence" of your ISP, it's likely to be reasonably close.Code: Select all
[Rainmeter] Update=1000 DynamicWindowSize=1 AccurateText=1 [Variables] [MeasureLocation] Measure=WebParser Url=http://ip-api.com/json RegExp=(?siU)"city":"(.*)".*"country":"(.*)".*"regionName":"(.*)" FinishAction=[!CommandMeasure MeasureWeatherCode "Update"] [MeasureCity] Measure=WebParser URL=[MeasureLocation] StringIndex=1 [MeasureCountry] Measure=WebParser URL=[MeasureLocation] StringIndex=2 [MeasureRegion] Measure=WebParser URL=[MeasureLocation] StringIndex=3 [MeasureWeatherCode] Measure=WebParser Url=http://wxdata.weather.com/wxdata/search/search?where=[&MeasureCity] [&MeasureRegion] [&MeasureCountry] DynamicVariables=1 RegExp=(?siU).*<loc id="(.*)" [MeasureCode] Measure=WebParser URL=[MeasureWeatherCode] StringIndex=1 [MeterBack] Meter=Shape Shape=Rectangle 1,1,302,132 | StrokeWidth 1 | Stroke Color 150,150,150,255 | Fill Color 47,47,47,120 [MeterLocation] Meter=String MeasureName=MeasureCity MeasureName2=MeasureRegion MeasureName3=MeasureCountry X=150 Y=20 FontSize=14 FontColor=255,255,255,255 AntiAlias=1 StringAlign=Center Text=%1#CRLF#%2#CRLF#%3 [MeterCode] Meter=String MeasureName=MeasureCode X=r Y=10R FontSize=12 FontColor=255,255,255,255 AntiAlias=1 StringAlign=Center
I really think you need to use the combination of "city/region/country" to zero in. City and country alone will give you just boatloads of hits for most common names.
-
- Posts: 207
- Joined: October 4th, 2019, 2:46 pm
Re: Generate Automatic WeatherCode from IP address in use
It's working!!
Although I still have the question with :
"FinishAction=[!CommandMeasure MeasureWeatherCode "Update"]
Maybe stupid question, but WHY and why at this location?"
Although I still have the question with :
"FinishAction=[!CommandMeasure MeasureWeatherCode "Update"]
Maybe stupid question, but WHY and why at this location?"
You do not have the required permissions to view the files attached to this post.
Last edited by JamX on October 5th, 2019, 12:28 pm, edited 1 time in total.
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Generate Automatic WeatherCode from IP address in use
Thank you for these useful information.jsmorley wrote: ↑October 4th, 2019, 11:26 pm WebParser doesn't detect your browser of course. But when you access a remote site, that site can query your system for certain things. Most browsers are designed to answer these queries, but for the most part WebParser is not. What WebParser can do is provide a UserAgent string, which will tell the remote site that you are using some defined browser (which is a lie, you are using WebParser), and that can be useful on a site that for instance outputs something slightly different when accessed with Chrome vs. Microsoft IE.
Let's see if I understood well the essence of the UserAgent option. If I set this option to any of here listed strings, the site open by a WebParser measure sees like the appropriate browser opened it and will act accordingly.
So if for instance I set the UserAgent to UserAgent=Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201, the site acts like a Mozilla Firefox 2.2 would open it.
Is this correct?
-
- Developer
- Posts: 22631
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Generate Automatic WeatherCode from IP address in use
Correct.balala wrote: ↑October 5th, 2019, 11:40 am Thank you for these useful information.
Let's see if I understood well the essence of the UserAgent option. If I set this option to any of here listed strings, the site open by a WebParser measure sees like the appropriate browser opened it and will act accordingly.
So if for instance I set the UserAgent to UserAgent=Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201, the site acts like a Mozilla Firefox 2.2 would open it.
Is this correct?
I'd be leery of telling it I'm using a 15 year old browser though...
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania