It is currently April 20th, 2024, 2:45 pm

Download an image with WebParser

Get help with creating, editing & fixing problems with skins
User avatar
Polaris
Posts: 4
Joined: May 22nd, 2011, 12:07 am

Download an image with WebParser

Post by Polaris »

Hello there!

I'm trying to make my own weather skin, but I have an issue about downloading the icon. I did the WebParserTest and the light turns green, so it doesn't come from the connection
There is my script:
[Variables]
URL=http://fr.weather.com/weather/today-Lyon-FRXX0055


[MeasureWeather]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#URL#
UpdateRate=900
RegExp="(?siU)<div id="today_current"><div id="current_left"><div id="current_box"><div id="current_box_icon"><img class="transparent" src="(.*)" width=".*" height=".*" alt=""></div><div id="current_box_temp">(.*)</div><div id="current_box_cond"><font color="#666666">Temp. ressentie (.*)</font><br></div> <br clear="all" /> <div style="text-align:center; padding-top: 5px;"> <b>(.*)</b> </div> </div> <div id="current_updated" style="width:207px;text-wrap:normal;">;*<BR> Station d’observation :Amberieu </div> </div> <div id="current_right"> <strong>Vent</strong><br>(.*)<br><br> <strong>Humidité</strong><br>(.*)<br> <br> <strong>Pression</strong><br>(.*)<br><br> <strong>Point de rosée</strong><br>(.*)<br> <br> <strong>Visibilité</strong><br>(.*)</div>"



[MeasureTodayIcon]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeather]
StringIndex=1
Download=1

[MeterTodayIcon]
Meter=IMAGE
MeasureName=MeasureTodayIcon
W=30
H=30
PreserveAspectRatio=1
AntiAlias=1
x=0
y=0
I've been messing around for a long time, but I just can't find what's wrong. Worst of all, I'm sure that the problem is ridiculously easy to solve, but I'm stuck on it since this morning (or yesterday morning, now). Could you help me please?
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Download an image with WebParser

Post by jsmorley »

I will only be of limited help as I don't speak French, but when I put in that URL and your RegExp in RainRegExp I get an error that all matches cannot be found. So there is something amiss with your Regular Expression. You might want to get RainRegExp at http://rainmeter.net/forum/viewtopic.php?f=18&t=769 so you can debug your RegExp and get it working. You need to get the number of the icon it is displaying, without the .png extension. You want it to just return (for instance as of this momemt) 33 in a StringIndex and then your code as is should work fine.

As an aside, I generally suggest that folks not "screen scrape" web sites unless there is no alternative using ATOM or RSS. Is there no feed for the French version of Weather.com you could use? Aside from being easier to parse, there is always the risk that the layout of the site will change, which any decent site does pretty regularly, and you are going to be constantly chasing changes. Screen scraping works and is ok, but not the preferred solution if a feed is available.
User avatar
Polaris
Posts: 4
Joined: May 22nd, 2011, 12:07 am

Re: Download an image with WebParser

Post by Polaris »

I tried to use RainRegExp to fix the parsing, but I failed really hard. I wouldn't use the RSS feed cause there are not many informations. By exemple, I'd like to have the informations about the wind (strong, direction etc), but there are not mentioned in the RSS feed. There isn't the icon too. It's a pity, but it's not really important, I'm gonna try with the RSS feed and use Substitute to get pictures instead of text ans see what happen.

Thank you very much for your reply!
User avatar
GhostMatrix
Rainmeter Sage
Posts: 141
Joined: April 18th, 2009, 8:26 pm
Location: Montreal, Quebec, Canada 45.5658°N, 73.5898°W UTC -5

Re: Download an image with WebParser

Post by GhostMatrix »

@Polaris
Salut!


Like "jsmorley" already said RSS feed will be easier to parse, but in your case the feed available don't suit your needs.
You really have to study the website when you parsing the source code of a web page, some have dynamic codes who change when a particular condition occur and will break the RegExp code.

If you want to download the weather icon you have to add: DownloadFile=image.png this will create a DownloadFile folder in the skin, and the icon will be replace each time with the name image.png
if you don't the image will be downloaded in the Rainmeter Temp folder, but you could end up with more than one image (33.png 26.png etc)

[Measure_Image]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeather]
StringIndex=1
Download=1
DownloadFile=image.png


[Meter_Image]
Meter=IMAGE
MeasureName=Measure_Image
X=20
Y=20

Also you have to avoid French word with punctuation like: <strong>Humidité</strong><br> the webparser of Rainmeter don't like those punctuations in the RegExp code.
Replace: <strong>Humidité</strong><br> like this: <strong>.*</strong><br>

I did a RegExp code with the web page behaviour that I have encounter at the moment, the code seem to work for now...

Code: Select all


-------------------------------------------
RegExp="(?siU)<div id="current_box_icon"><img class="transparent" src="(.*)".*<div id="current_box_temp">(.*)</div>.*<font color="#666666">Temp\. ressentie\s*(\S.*)\s*</font><br>.*<b>(.*)</b>.*<strong>Vent</strong><br>\s*(\S.*)\s*\n\s*(\S.*)\s*<br><br>.*<strong>.*</strong><br>\s*(\S.*)<br>.*<strong>Pression</strong><br>\s*(\S.*)<br>.*<strong>.*</strong><br>\s*(\S.*)<br>.*<strong>.*</strong><br>\s*(\S.*)\s*</div>"

[MeasureWeather] (Index  1) http://i.fr.imwx.com/global/images/93x93/30.png
[MeasureWeather] (Index  2) 28&deg;C
[MeasureWeather] (Index  3) 27&deg;C
[MeasureWeather] (Index  4) Peu nuageux
[MeasureWeather] (Index  5) Du nord à
[MeasureWeather] (Index  6) 11 km/h
[MeasureWeather] (Index  7) 30%
[MeasureWeather] (Index  8) 1 018,96 mb
[MeasureWeather] (Index  9) 9&deg;C
[MeasureWeather] (Index 10) 10 km
--------------------------------------------

Skin Code:

[Rainmeter]
Author=GhostMatrix
Update=1000

[Variables]
Url=http://fr.weather.com/weather/today-Lyon-FRXX0055
FontName=Arial
TxtColor=255,255,255,200


[MeasureWeather]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url=#Url#
RegExp="(?siU)<div id="current_box_icon"><img class="transparent" src="(.*)".*<div id="current_box_temp">(.*)</div>.*<font color="#666666">Temp\. ressentie\s*(\S.*)\s*</font><br>.*<b>(.*)</b>.*<strong>Vent</strong><br>\s*(\S.*)\s*\n\s*(\S.*)\s*<br><br>.*<strong>.*</strong><br>\s*(\S.*)<br>.*<strong>Pression</strong><br>\s*(\S.*)<br>.*<strong>.*</strong><br>\s*(\S.*)<br>.*<strong>.*</strong><br>\s*(\S.*)\s*</div>"
StringIndex=1
CodePage=28591
FinishAction=!RainmeterRedraw
Debug=1

[Measure_Image]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeather]
StringIndex=1
Download=1
DownloadFile=image.png

[Measure_Temperature]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeather]
StringIndex=2
Substitute="&deg;C":"°"

[Measure_Temperature_Ressentie]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeather]
StringIndex=3
Substitute="&deg;C":"°"

[Measure_Condition]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeather]
StringIndex=4

[Measure_Vent_A]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeather]
StringIndex=5
Substitute="Ã":"à"

[Measure_Vent_B]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeather]
StringIndex=6

[Measure_Humidite]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeather]
StringIndex=7

[Measure_Presion]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeather]
StringIndex=8
Substitute="Ã":""

[Measure_DewPoint]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeather]
StringIndex=9
Substitute="&deg;C":"°"

[Measure_Visibilite]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeather]
StringIndex=10

[Meter_Image]
Meter=IMAGE
MeasureName=Measure_Image
X=20
Y=20

[Meter_Background]
Meter=IMAGE
ImageName=img\back.png
X=0
Y=0

[Meter_Temperature]
MeasureName=Measure_Temperature
Meter=STRING
X=150
Y=55
FontColor=#TxtColor#
StringStyle=bolditalic
FontSize=17
StringAlign=CENTER
FontFace=#FontName#
Text="%1"
Antialias=1


[Meter_Condition]
MeasureName=Measure_Condition
Meter=STRING
X=123
Y=110
FontColor=#TxtColor#
StringStyle=bolditalic
FontSize=10
StringAlign=CENTER
FontFace=#FontName#
Text="%1"
Antialias=1

[Meter_Vent_Titre]
Meter=STRING
X=125
Y=130
FontColor=#TxtColor#
StringStyle=bolditalic
FontSize=9
StringAlign=CENTER
FontFace=#FontName#
Text="Vent:"
Antialias=1

[Meter_Vent]
MeasureName=Measure_Vent_A
MeasureName2=Measure_Vent_B
Meter=STRING
X=0r
Y=11r
FontColor=#TxtColor#
StringStyle=bolditalic
FontSize=9
StringAlign=CENTER
FontFace=#FontName#
Text="%1%2"
Antialias=1



GM
If at first you don't succeed; call it version 0.1

Image
User avatar
xenium
Posts: 865
Joined: January 4th, 2018, 9:52 pm

Re: Download an image with WebParser

Post by xenium »

Hi,
I would like to download the image from capture.png but I can not
What am I doing wrong?
TestDownloadImage.zip
You do not have the required permissions to view the files attached to this post.
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Download an image with WebParser

Post by fonpaolo »

For what I can see, there's no image to download...
I can't find the image link in the page, so i suppose it's from another source.

Keep in mind that downloading an image from a web page is already very difficult if the images are in the main layout, if then your image is loaded, linked by a javascript and so on, it's simply impossible.
I can't find the image link in the page, so i suppose it's from another source.
User avatar
balala
Rainmeter Sage
Posts: 16150
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Download an image with WebParser

Post by balala »

xenium wrote:Hi,
I would like to download the image from capture.png but I can not
What am I doing wrong?
TestDownloadImage.zip
First of all, we should have to find the image you would like to download. As fonpaolo said, this seems a bit more difficult then you thought (I suppose).
So, which image from the site would you like to download? Maybe post a screenshot, indicating the wanted image.

And just as a side note, why are you raising up an almost 7 years old thread?
User avatar
xenium
Posts: 865
Joined: January 4th, 2018, 9:52 pm

Re: Download an image with WebParser

Post by xenium »

this is the image
is the first graph, PM2.5
download.png
You do not have the required permissions to view the files attached to this post.
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Download an image with WebParser

Post by fonpaolo »

xenium wrote:this is the image
is the first graph, PM2.5
download.png
Well, this is the "name" of your image:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATYAAAAcCAYAAADr/JNNAAAJQklEQVR4Xu1cbUxU2Rl+D4wElYVopWI2ZoS6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32LiwMZKub2njMkKPWX8plY9oX9P2I37L5xZegKP24fc6aLbCEMxVVNHNdGbA0yq4sPCIlY9ewLiwMWoFLmxLAZJZfy0lCa9rqfNh09ei/Vs7HmeWV9hO7fuTD5YYdQPCKSLn57qsb4JoBYkL20sITE1MRg0hNkzQ5EPL55xTn7CALmjwEbtZiYVtx5NIc1/4RMOc6YnOiOC/dMcm8Q2JfEyDCxsXtiXpCX+rzthhK6MDoitMX2HDeMzXab249vMn3712dvlo/lzFfHENQkKvMdnTElsSKrUUFcEBcm2fCVEi6J+4S5KJl1+sGD4ns33fvmGGfKbkSdA7WhE8FdIBCmGjExjaJSSreOkdG+Xem2KNK4IEz2cGmABzEkEvbErhSdmPvo6NC5v/PT9Gr6Nf7nGWFvHKCtvJ/T/1QUb1/D48V7l/XHPOQc5Ph95TYEVhBox8VzIknyzbfSaOnxYHIXz8UOz3kzHdf1n55dx9ciXx5MIm8tUpVoLNhW1RistMaAPNMdDyihV/2OBAW0tWKy5244jgyR0bLTFDp4U+5zdWPL7hwR9X/euNeUwh+5WrBdgzBlk2371MWpr5iWcmJLQ5tWT6OicAWnzEZh2D6dAHijgwWp6IxQvzB4rHN9yj4g8bHGiry06QWOHJhU1iJ0dbKMov39MyUDFhk9ZJBF5j0dZdqZdhdPMqt4dNiycXNi5stOK4qHgubP73aOkERmohpy2x1PnQj8+FLcCEjfbJRNcQ4k9ciZ3ivG+yePKgJWzwOAZp60iLG208FzbR3zNjU1hWBaEdJ9jj6YnJhW0xjkpqnigl5PT8UabfqX9Pkb88CLRC0eVDT0wubFzYaFnz/3ipBZ5+fL4U5UtRt+vmwsaFjQvbLAL0SkrnPGjHV8q60+YpdTwtRbmwfYOY1HWhHV8pPtPzR9q+psVNlM//A8lha5VmFuwBAAAAAElFTkSuQmCC
:17what
User avatar
balala
Rainmeter Sage
Posts: 16150
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Download an image with WebParser

Post by balala »

fonpaolo wrote:Well, this is the "name" of your image:
:17angry Yep, exactly. But me at least have no idea what to do with a such "thing". :17angry