VoxCommando
Help and Support (Using VoxCommando) => Other Plugins => Topic started by: IKROWNI on April 18, 2018, 09:30:01 PM
-
I'm trying to use robobrowser to scrape info from my electric provider and create a sensor that monitor my electric use and payment owed.
right now ive got it to write
<strong>Payment: $195.17</strong>
to the text file. How do i trim this part before it gets printed?
<strong>Payment: </strong>
All i want is $195.17 to be saved into the text file.
-
you would need to use regex to get just the dollar amount from that string.
use action Results.Regex
<strong>Payment:\s(.*?)</strong>
example command;
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.4.0-->
<command id="674" name="Regex" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>Results.SetLastResult</cmdType>
<params>
<param><strong>Payment: $195.17</strong></param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.RegEx</cmdType>
<params>
<param><strong>Payment:\s(.*?)</strong></param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>{Match.1.1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</command>
-
hey thanks i appreciate the help.
-
use action Results.Regex
<strong>Payment:\s(.*?)</strong>
Okay i got that working but when i try to use the same thing with the due date im getting this
<div class="gwt-Label ce-contentHeadingBolder">05/02/2018</div>
so i tried using Results.Regex like this
<div class="gwt-Label ce-contentHeadingBolder">(.*?)</div>/
but im not getting the same kind of results where i should just get 05/02/2018 in the new txt file.
Is there some reason why this wouldn't work the same as the other?
-
Looking at what you posted you need to replace spaces with
\s
In the regex tool there is a help button that has links to working with regex. Regex has a learning curve, but worth learning. And very powerful
-
replaced all of the spaces with \s like so
<div\sclass="gwt-Label\sce-contentHeadingBolder">(.*?)</div>/
still doesnt seem to be working properly. I checked out the regex cheat sheet but its still very confusing.
-
in your regex pattern you have a trailing "/" at the end of your Regex, if you remove that / then your regex pattern should work
Old Regex
<div\sclass="gwt-Label\sce-contentHeadingBolder">(.*?)</div>/
New Regex
<div\sclass="gwt-Label\sce-contentHeadingBolder">(.*?)</div>
-
Awesome i just wanna say thanks again. I was able to get all of my bills nicely displayed in my home assistant using this.
(https://i.imgur.com/px3jo9o.png)
Wish i could clean up those dates and make them all use the same formatting but im not gonna be picky.
Next up is to add my wifes car stats using this.
-
cleaning up the dates is simple, use Results.RegExReplace to replace the - with /
example date clean up
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.4.0-->
<command id="675" name="date cleen up" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>Results.RegExReplace</cmdType>
<params>
<param>-</param>
<param>/</param>
<param>04-09-2018</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</command>