I'm a newbie in writing rainmeter coding...I was just recently editing other people's codes for personal use
Just then, I ran into http://gdata.youtube.com/feeds/base/users/tvb/uploads?alt=rss&v=2&orderby=published ...
I want to parse the site but was stuck when I found some doubly encoded Chinese HTML entity such as 文
I saw other posts indicating the problem http://rainmeter.net/forum/viewtopic.php?f=14&t=6814 but there wasn't any solution given.
If only I can substitute & to & first before using DecodeCharacterReference
Is that even possible..?
Please help me....
It is currently May 10th, 2024, 11:38 am
Doubly encoded Chinese HTML entity
-
- Posts: 7
- Joined: August 29th, 2012, 3:53 am
-
- Rainmeter Sage
- Posts: 889
- Joined: September 6th, 2011, 6:34 am
Re: Doubly encoded Chinese HTML entity
Hm, I don't know if there is a built-in way of handling this, but in the worst case you might use Download=1 on the WebParser measure to get the whole text file, then use a Lua script to read the file and replace the symbols, then use another WebParser with DecodeCharacterReference to read the file and replace the unicode codes (at least I think that should be possible).
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
-
- Posts: 7
- Joined: August 29th, 2012, 3:53 am
Re: Doubly encoded Chinese HTML entity
Thanks for ur reply...
However...I had never wrote a lua script before...I think I ll give it a try but I might take time...
U mentioned download=1...
I tried but I couldn't find the file downloaded
I tried specify downloadfile=page.txt
All I get is just a blank 'downloadfile' folder
I m sorry...did I did something wrong..?
However...I had never wrote a lua script before...I think I ll give it a try but I might take time...
U mentioned download=1...
I tried but I couldn't find the file downloaded
I tried specify downloadfile=page.txt
All I get is just a blank 'downloadfile' folder
I m sorry...did I did something wrong..?
-
- Rainmeter Sage
- Posts: 889
- Joined: September 6th, 2011, 6:34 am
Re: Doubly encoded Chinese HTML entity
Normally, if you add both download=1 and downloadfile=page.txt to the WebParser measure, a file "page.txt" should be created in your skin's folder and contain all the page source code. Can you post your code here? (in code tags please)
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
-
- Posts: 7
- Joined: August 29th, 2012, 3:53 am
Re: Doubly encoded Chinese HTML entity
Ok...heres the code...but I only copied some of it I think is important...is this enough..?
One more thing...once I wrote these codes "Download=1 DownloadFile=page.txt" in...the description stopped displaying
[Variables]
GET=.*<title>(.+)</title>.*img alt="" src=\"(.+)\".*;span>(.+).</span.*Views:</span>\s(.*)&.*<link>(.+)&
[VIDEO]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=10000
Url=http://gdata.youtube.com/feeds/base/users/TVB/uploads?alt=rss&v=2&orderby=published
RegExp="(?siU)<title>(.+)</title>.*<title>(.+)</title>.*<link>(.+)</link>.*<link>(.+)</link>#GET##GET##GET##GET##GET##GET##GET##GET#"
FinishAction=!RainmeterUpdate "#CURRENTCONFIG#"
[T1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[VIDEO]
StringIndex=5
DecodeCharacterReference=1
[D1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[VIDEO]
StringIndex=7
DecodeCharacterReference=1
Download=1
DownloadFile=page.txt
[Title1]
MeasureName=T1
Meter=STRING
X=135
Y=120
FontSize=10
FontFace=Segoe UI
AntiAlias=1
ClipString=1
[Desc1]
MeasureName=D1
Meter=STRING
X=138
Y=145
FontSize=10
FontFace=Segoe UI
AntiAlias=1
ClipString=1
One more thing...once I wrote these codes "Download=1 DownloadFile=page.txt" in...the description stopped displaying
[Variables]
GET=.*<title>(.+)</title>.*img alt="" src=\"(.+)\".*;span>(.+).</span.*Views:</span>\s(.*)&.*<link>(.+)&
[VIDEO]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=10000
Url=http://gdata.youtube.com/feeds/base/users/TVB/uploads?alt=rss&v=2&orderby=published
RegExp="(?siU)<title>(.+)</title>.*<title>(.+)</title>.*<link>(.+)</link>.*<link>(.+)</link>#GET##GET##GET##GET##GET##GET##GET##GET#"
FinishAction=!RainmeterUpdate "#CURRENTCONFIG#"
[T1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[VIDEO]
StringIndex=5
DecodeCharacterReference=1
[D1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[VIDEO]
StringIndex=7
DecodeCharacterReference=1
Download=1
DownloadFile=page.txt
[Title1]
MeasureName=T1
Meter=STRING
X=135
Y=120
FontSize=10
FontFace=Segoe UI
AntiAlias=1
ClipString=1
[Desc1]
MeasureName=D1
Meter=STRING
X=138
Y=145
FontSize=10
FontFace=Segoe UI
AntiAlias=1
ClipString=1
-
- Rainmeter Sage
- Posts: 889
- Joined: September 6th, 2011, 6:34 am
Re: Doubly encoded Chinese HTML entity
You put Download=1 etc. on the main measure. Once you do that, WebParser will no longer parse the site of the url (so you can't use "child" measures of this WebParser measure). It will just download the file and do nothing else. You'll need a second WebParser measure to parse the file from disk. It might look something like this:
You use the first measure to download the page source and the second one to parse the downloaded file's contents. You can then use a Lua script to modify the downloaded file as needed before parsing it with the second WebParser, but that's a different story.
Code: Select all
[Variables]
GET=.*<title>(.+)</title>.*img alt="" src=\"(.+)\".*;span>(.+).</span.*Views:</span>\s(.*)&.*<link>(.+)&
[Downloader]
Measure=Plugin
Plugin=WebParser
UpdateRate=10000
Url=http://gdata.youtube.com/feeds/base/users/TVB/uploads?alt=rss&v=2&orderby=published
FinishAction=!UpdateMeasure "VIDEO"
Download=1
DownloadFile=#ROOTCONFIGPATH#page.txt
[VIDEO]
Measure=Plugin
Plugin=WebParser
UpdateRate=10000
Url=file://#ROOTCONFIGPATH#page.txt
RegExp="(?siU)<title>(.+)</title>.*<title>(.+)</title>.*<link>(.+)</link>.*<link>(.+)</link>#GET##GET##GET##GET##GET##GET##GET##GET#"
FinishAction=!Update "#CURRENTCONFIG#"
DecodeCharacterReference=1
[T1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[VIDEO]
StringIndex=5
[D1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[VIDEO]
StringIndex=7
[Title1]
MeasureName=T1
Meter=STRING
X=135
Y=120
FontSize=10
FontFace=Segoe UI
AntiAlias=1
ClipString=1
[Desc1]
MeasureName=D1
Meter=STRING
X=138
Y=145
FontSize=10
FontFace=Segoe UI
AntiAlias=1
ClipString=1
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
-
- Posts: 7
- Joined: August 29th, 2012, 3:53 am
Re: Doubly encoded Chinese HTML entity
Oo...I see...I'll try that later...need to get dinner 1st...
Thanks a lot...
Thanks a lot...
-
- Posts: 7
- Joined: August 29th, 2012, 3:53 am
Re: Doubly encoded Chinese HTML entity
I tried the codings...it works...now it had created a text file
Thanks...
Now...I'll just have to figure out a way to change the file downloaded...
Thanks...
Now...I'll just have to figure out a way to change the file downloaded...
-
- Posts: 7
- Joined: August 29th, 2012, 3:53 am
Re: Doubly encoded Chinese HTML entity
I got it...I got it..!
Finally...we succeeded
Thank you so much...
This is my & eliminator.lua
function Initialize()
end
function Update()
local file1=io.open(SKIN:MakePathAbsolute('DownloadFile\\page.txt'), 'r')
local filedata=file1:read('*all')
local newfiledata=string.gsub(filedata,"&","&")
file1:close()
local file2=io.open(SKIN:MakePathAbsolute('DownloadFile\\edited.txt'), 'w+')
file2:write(newfiledata)
file2:close()
end
MerlinTheRed...I ll be lost without you...thank you so much...my friend
Finally...we succeeded
Thank you so much...
This is my & eliminator.lua
function Initialize()
end
function Update()
local file1=io.open(SKIN:MakePathAbsolute('DownloadFile\\page.txt'), 'r')
local filedata=file1:read('*all')
local newfiledata=string.gsub(filedata,"&","&")
file1:close()
local file2=io.open(SKIN:MakePathAbsolute('DownloadFile\\edited.txt'), 'w+')
file2:write(newfiledata)
file2:close()
end
MerlinTheRed...I ll be lost without you...thank you so much...my friend
-
- Rainmeter Sage
- Posts: 889
- Joined: September 6th, 2011, 6:34 am
Re: Doubly encoded Chinese HTML entity
Nice . And you even got the Lua script figured out by yourself. Glad I could help
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!