It is currently April 24th, 2024, 3:19 pm

Webparser Not Downloading Image.

Get help with creating, editing & fixing problems with skins
Pyros_Enjoy_Pie
Posts: 7
Joined: August 2nd, 2017, 1:32 am

Webparser Not Downloading Image.

Post by Pyros_Enjoy_Pie »

So I'm making a Rainmeter skin which finds your latitude and longitude using your ip address and then punches the coordinates into a Google Maps Static Map API to spit out an image and marker for your current location. I had it working, but now I cannot seem to get the damn webparser to download the image. The problem does not seem to be with the google maps api url because I can punch that into Chrome just fine providing I change the Measures to actual numbers. I feel like I'm missing something incredibly simple.

Code: Select all

[Rainmeter]
Update=1000


[MeasureMap]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL="https://maps.googleapis.com/maps/api/staticmap?center=[MeasureIP2Lat],[MeasureIP2Long]&size=640x400&zoom=9&maptype=hybrid&markers=icon:http://i.imgur.com/MN9NZ6g.png%7C[MeasureIP2Lat],[MeasureIP2Long]&format=png"
Debug=1
StringIndex=1
Download=1
DownloadFile="map.png"
DynamicVariables=1
FinishAction=[!UpdateMeter *][!Redraw]
DynamicVariables=1


[MeterMap]
MeasureName=MeasureMap
Meter=IMAGE
X=30
Y=31
MouseLeaveAction=[!HideMeterGroup Interface][!Redraw]
MouseOverAction=[!ShowMeterGroup Interface][!Redraw]


[MeterMapBack]
Meter=IMAGE
ImageName="DownloadFile\map.png"
X=30
Y=31


[MeasureSiteAll]
Measure=Plugin
Plugin=WebParser
URL=http://www.tell-my-ip.com/index.html
RegExp=(?siU)<td.*>Your IP Address:</td><td>(.*)</td>.*<td>Country:</td>.*<img src="(.*)"> (.*)</td>.*<td>Region:</td><td>(.*)</td>.*<td>City:</td><td>(.*)</td>.*<td>Latitude:</td><td>(.*)</td>.*<td>Longitude:</td><td>(.*)</td>
UpdateRate=1000


[MeasureIP2Lat]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureSiteAll]
UpdateRate=1000
StringIndex=6


[MeasureIP2Long]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureSiteAll]
UpdateRate=1000
StringIndex=7
EDIT: The only error I am getting from this is that the it cannot open the image, but that's because the image is not being downloaded. I also checked the "Webparser Tester" and got back all green lights.
Last edited by Pyros_Enjoy_Pie on August 3rd, 2017, 1:42 am, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Webparser Not Downloading Image.

Post by jsmorley »

If you use [SomeMeasure] in the URL of a WebParser measure, it makes the assumption that it is a child in a parent-child relationship, and will be looking to get some data using StringIndex from the parent measure.

That isn't what you are doing here. You are using [SomeMeasuere] (multiple times) as a [SectionVariable], where you want this to be a parent measure, but use those [SectionVariable] values in the URL.

To do that, you must lead the name of the measure with a & character, like [&SomeMeasure], and use DynanmicVariables=1 on the measure. (which you did do)

So:

Code: Select all

URL="https://maps.googleapis.com/maps/api/staticmap?center=[&MeasureIP2Lat],[&MeasureIP2Long]&size=640x400&zoom=9&maptype=hybrid&markers=icon:http://i.imgur.com/MN9NZ6g.png%7C[&MeasureIP2Lat],[&MeasureIP2Long]&format=png"
DynamcVariables=1
https://docs.rainmeter.net/manual/plugins/webparser/#Dynamic
If you want to use the current value of a measure in a dynamic way as a Section Variable, rather than as a reference to a "parent" WebParser measure, you must prefix the name of the measure with the & character.

URL=http://SomeSite.com\[&WebMeasure]
P.S. There must still be something wrong with this, as I get an image of the middle of the ocean, where I"m pretty sure I don't live. Wait, let me look out the window. Nope. However, I do get an image...
1.jpg
You do not have the required permissions to view the files attached to this post.
Pyros_Enjoy_Pie
Posts: 7
Joined: August 2nd, 2017, 1:32 am

Re: Webparser Not Downloading Image.

Post by Pyros_Enjoy_Pie »

After making the changes you said I am now also getting an image, however I am also getting the indicator in the middle of the ocean. The skin I am using is a modification of a different one so now I have put back all of the original parts for the latitude/longitude finder.

Code: Select all

[Rainmeter]
Update=1000

[Variables]
locationsub="":"0"

[MeasureSiteAll]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=http://www.tell-my-ip.com/index.html
RegExp=(?siU)<td.*>Your IP Address:</td><td>(.*)</td>.*<td>Country:</td>.*<img src="(.*)"> (.*)</td>.*<td>Region:</td><td>(.*)</td>.*<td>City:</td><td>(.*)</td>.*<td>Latitude:</td><td>(.*)</td>.*<td>Longitude:</td><td>(.*)</td>
UpdateRate=1000

[MeasureIP2Lat]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureSiteAll]
RegExp=
UpdateRate=1000
Substitute=#locationsub#
StringIndex=6
Debug=2

[MeasureIP2Long]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureSiteAll]
UpdateRate=1000
Substitute=#locationsub#
StringIndex=7

[MeasureMap]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateDivider=-1
URL="https://maps.googleapis.com/maps/api/staticmap?center=[&MeasureIP2Lat],[&MeasureIP2Long]&size=640x400&zoom=8&maptype=hybrid&markers=icon:http://i.imgur.com/MN9NZ6g.png%7C[&MeasureIP2Lat],[&MeasureIP2Long]&format=png"
DynamcVariables=1
Debug=1
StringIndex=1
Download=1
DownloadFile="map.png"
DynamcVariables=1
FinishAction=[!UpdateMeter *][!Redraw]
DynamcVariables=1

[MeterMap]
MeasureName=MeasureMap
Meter=IMAGE
X=30
Y=31

[MeterMapBack]
Meter=IMAGE
ImageName="DownloadFile\map.png"
X=30
Y=31

However the problem I saw with the original skin (the latitude/longitude locator) was that it seems to be replacing whatever values for the latitude/longitude from the website with 0, in fact if you change the 0 to any other number in locationsub the you will get an image at whatever number you put in. So now I have the problem of how can I get the [MeasureMap] to be given the correct coordinates. [MeasureIP2Lat] and [MeasureIP2Lng] are supposed to retrieve their respective coordinates from [MeasureSiteAll].
User avatar
balala
Rainmeter Sage
Posts: 16165
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Webparser Not Downloading Image.

Post by balala »

After a few tries of the posted code(s), I figured out the followings: I get the same image as jsmorley (posted in his last reply). I'm living in eastern part of Europe, so if I get the same image, probably something is going very wrong.
So, what could be the cause? Finally I found that after the [MeasureIP2Lat] and [MeasureIP2Long] measures get their values, the [MeasureMap] (which is downloading the image) should be updated, to use the new values and get the proper image. For this, you have to add the following option to the [MeasureSiteAll] measure: FinishAction=[!CommandMeasure "MeasureMap" "Update"].
That's all.
Pyros_Enjoy_Pie
Posts: 7
Joined: August 2nd, 2017, 1:32 am

Re: Webparser Not Downloading Image.

Post by Pyros_Enjoy_Pie »

I have updated [MeasureSiteAll] to reflect that change, its now

Code: Select all

[MeasureSiteAll]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=http://www.tell-my-ip.com/index.html
RegExp=(?siU)<td.*>Your IP Address:</td><td>(.*)</td>.*<td>Country:</td>.*<img src="(.*)"> (.*)</td>.*<td>Region:</td><td>(.*)</td>.*<td>City:</td><td>(.*)</td>.*<td>Latitude:</td><td>(.*)</td>.*<td>Longitude:</td><td>(.*)</td>
UpdateRate=1000
FinishAction=[!CommandMeasure "MeasureMap" "Update"]
However I am still getting an image of the ocean
map.png
It seems to me that the [MeasureIP2Lat] and [MeasureIP2Lng] are still replacing their values with zero because if the api link were still just using the literal [MeasureIP2Lat] and [MeasureIP2Lng] instead of using them as variables then it would show the image that jsmorley posted.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Webparser Not Downloading Image.

Post by jsmorley »

This seems to work for me:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
locationsub="":"0"

[MeasureSiteAll]
Measure=Plugin
Plugin=WebParser
URL=http://www.tell-my-ip.com/index.html
RegExp=(?siU)<td.*>Your IP Address:</td><td>(.*)</td>.*<td>Country:</td>.*<img src="(.*)"> (.*)</td>.*<td>Region:</td><td>(.*)</td>.*<td>City:</td><td>(.*)</td>.*<td>Latitude:</td><td>(.*)</td>.*<td>Longitude:</td><td>(.*)</td>
UpdateRate=1000
ForceReload=1
FinishAction=[!UpdateMeasure MeasureMap][!CommandMeasure "MeasureMap" "Update"]

[MeasureIP2Lat]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSiteAll]
UpdateRate=1000
Substitute=#locationsub#
StringIndex=6

[MeasureIP2Long]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSiteAll]
UpdateRate=1000
Substitute=#locationsub#
StringIndex=7

[MeasureMap]
Measure=Plugin
Plugin=WebParser
URL="https://maps.googleapis.com/maps/api/staticmap?center=[&MeasureIP2Lat],[&MeasureIP2Long]&size=640x400&zoom=8&maptype=hybrid&markers=icon:http://i.imgur.com/MN9NZ6g.png%7C[&MeasureIP2Lat],[&MeasureIP2Long]&format=png"
Download=1
DownloadFile="map.png"
ForceReload=1
DynamicVariables=1
FinishAction=[!UpdateMeter *][!Redraw]

[MeterMap]
MeasureName=MeasureMap
Meter=IMAGE
X=30
Y=31
1.jpg
Be sure you completely restart Rainmeter before you test this, it is not unlikely that all the hammering on it trying to get this to work has created a "hung" instance of WebParser.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16165
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Webparser Not Downloading Image.

Post by balala »

For me it is working well, showing the adequate map. Here is my code besides jsmorley's one, please try this too:

Code: Select all

[MeasureMap]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=https://maps.googleapis.com/maps/api/staticmap?center=[&MeasureIP2Lat],[&MeasureIP2Long]&size=640x400&zoom=9&maptype=hybrid&markers=icon:http://i.imgur.com/MN9NZ6g.png%7C[&MeasureIP2Lat],[&MeasureIP2Long]&format=png
DynamcVariables=1
Debug=1
StringIndex=1
Download=1
DownloadFile=map.png
FinishAction=[!UpdateMeter *][!Redraw]

[MeterMap]
MeasureName=MeasureMap
Meter=IMAGE
X=30
Y=31
MouseLeaveAction=[!HideMeterGroup Interface][!Redraw]
MouseOverAction=[!ShowMeterGroup Interface][!Redraw]

[MeterMapBack]
Meter=IMAGE
ImageName=DownloadFile\map.png
X=30
Y=31

[MeasureSiteAll]
Measure=Plugin
Plugin=WebParser
URL=http://www.tell-my-ip.com/index.html
RegExp=(?siU)<td.*>Your IP Address:</td><td>(.*)</td>.*<td>Country:</td>.*<img src="(.*)"> (.*)</td>.*<td>Region:</td><td>(.*)</td>.*<td>City:</td><td>(.*)</td>.*<td>Latitude:</td><td>(.*)</td>.*<td>Longitude:</td><td>(.*)</td>
FinishAction=[!CommandMeasure "MeasureMap" "Update"]
UpdateRate=1000

[MeasureIP2Lat]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureSiteAll]
UpdateRate=1000
StringIndex=6

[MeasureIP2Long]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureSiteAll]
UpdateRate=1000
StringIndex=7
Does this code work for you? Because as I said, it does for me.
Last edited by balala on August 2nd, 2017, 5:04 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Webparser Not Downloading Image.

Post by jsmorley »

I guess the three copies of DynamicVariables=1 [MeasureMap] is just to be damn sure? :-)
User avatar
balala
Rainmeter Sage
Posts: 16165
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Webparser Not Downloading Image.

Post by balala »

jsmorley wrote:I guess the three copies of DynamicVariables=1 [MeasureMap] is just to be damn sure? :-)
Sorry, you're right. I messed up something.
But the code is still working.

Fixed!
Pyros_Enjoy_Pie
Posts: 7
Joined: August 2nd, 2017, 1:32 am

Re: Webparser Not Downloading Image.

Post by Pyros_Enjoy_Pie »

Alright so I used jsmorley's code and got back an image of the coordinates that that particular website was giving. However those coordinates were wrong, so I decided I needed to use a different website. This one has a slightly different setup in its html (instead of getting lat and long separately they come paired and with a "," such that the string index comes out to be xx.xxxx,yy.yyyy) so I adjusted the RegExp to get the new numbers, changed [MeasureIP2Lat] & [MeasureIP2Long] to [MeasureIP2LatLong) to reflect that now its coming over as just one string index instead of two, changed the URL so its reading as [&MeasureIP2LatLong] (as the string index is now xx.xxxx,yy.yyyy) instead of [&MeasureIP2Lat],[&MeasureIP2Long]. I checked the log to make sure [MeasureIP2LatLong] is coming up as the coordinates which were in the html for the website, it is. But once again I have come to the problem of its not downloading the damn image. Here's my skin again new and shiny.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
locationsub="":"0"

[MeasureSiteAll]
Measure=Plugin
Plugin=WebParser
URL=http://ipinfo.io/
RegExp=(?siU)<td data-loc="(.*)">
UpdateRate=1
ForceReload=1
FinishAction=[!UpdateMeasure MeasureMap][!CommandMeasure "MeasureMap" "Update"]

[MeasureIP2LatLong]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSiteAll]
UpdateRate=1
Substitute=#locationsub#
StringIndex=1
FinishAction=[!UpdateMeasure MeasureMap][!CommandMeasure "MeasureMap" "Update"]

[MeasureMap]
Measure=Plugin
Plugin=WebParser
URL="https://maps.googleapis.com/maps/api/staticmap?center=[&MeasureIP2LatLong]&size=640x400&zoom=8&maptype=hybrid&markers=icon:http://i.imgur.com/MN9NZ6g.png%7C[&MeasureIP2LatLong]&format=png"
Download=1
DownloadFile="map.png"
ForceReload=1
DynamicVariables=1
FinishAction=[!UpdateMeter *][!Redraw]

[MeterMap]
MeasureName=MeasureMap
Meter=IMAGE
X=30
Y=31