Extracting Tooltip from Onmouseover

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
Yurio
Posts: 3
Joined: Mon Apr 06, 2015 9:16 pm

Extracting Tooltip from Onmouseover

Post by Yurio » Mon Apr 06, 2015 9:56 pm

Hello fellow iMacros(u)sers :D

So far I've had lots of fun and great success with iMacros. However I seemed to have reached my limit of programming capability with this one particular case. :oops:

I've been trying to extract a Tooltip triggered by a mouseover event. I found the entire passage in the source code, so it's definitely exctractable right away, if anything I found out that iMacros has a feature to now trigger mouse events, but I didn't even get that far. I always hover over the respective thing on the website myself, just to see if iMacros will pick it up, but I'm not getting there.

The Code I'm trying to break, I changed the values a little bit.
(Note that whatever text I'm trying to extract appears twice, they are both the same and extracting one of them is enough for me.)

Code: Select all

<td class=" c73w"><span class="storage"><img src="../../img/storage7.jpg" onmouseout="UnTip()" onmouseover="Tip('Text I want to extract 1 <br/>Text I want to extract 1 )" class="storageBar"><div class="storageLevelDiv"><span onmouseout="UnTip()" onmouseover="Tip('Text I want to extract 1 <br/>Text I want to extract 2')" class="storageLevel">2.966.578</span></div></span></td>
I am trying to read the Tips basically. I know how to crop them and replace whatever I don't need, I also know how to extract the 2.966.578 part, I just can't seem to get the Tooltip.
I've had various tries, here are my last ones, including some thing I found on the forums here and tried out.

Code: Select all

//iimPlayCode("TAG POS=2 TYPE=SPAN ATTR=CLASS:storageLevel&&ONMOUSEOVER:Tip EXTRACT=TXT");
	//iimPlayCode("TAG POS=1 TYPE=TD ATTR=CLASS:onmouseover* EXTRACT=TXT");
	//iimPlayCode("TAG POS=7 TYPE=TD ATTR=CLASS:c73w:storageLevel&&ONMOUSEOVER:Tip EXTRACT=TXT");
	//iimPlayCode("TAG POS=7 TYPE=TD ATTR=CLASS:c73w CONTENT=EVENT:MOUSEOVER EXTRACT=TXT");
	//iimPlayCode("TAG POS=7 TYPE=SPAN ATTR=CLASS:c73w:storageLevel&&ONMOUSEOVER:Tip EXTRACT=TXT");
This I also found on the forums here, but building it into above TAGs always gives me an error claiming it was a wrong use of Command:Tag

Code: Select all

	//CONTENT=EVENT:MOUSEOVER
I would really appreciate if anyone could help me out there, how do I extract the Tip?
Thank you for your time and help!

Best regards,
Yurio
chivracq
Posts: 9507
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extracting Tooltip from Onmouseover

Post by chivracq » Tue Apr 07, 2015 1:14 pm

Yurio wrote:Hello fellow iMacros(u)sers :D

So far I've had lots of fun and great success with iMacros. However I seemed to have reached my limit of programming capability with this one particular case. :oops:

I've been trying to extract a Tooltip triggered by a mouseover event. I found the entire passage in the source code, so it's definitely exctractable right away, if anything I found out that iMacros has a feature to now trigger mouse events, but I didn't even get that far. I always hover over the respective thing on the website myself, just to see if iMacros will pick it up, but I'm not getting there.

The Code I'm trying to break, I changed the values a little bit.
(Note that whatever text I'm trying to extract appears twice, they are both the same and extracting one of them is enough for me.)

Code: Select all

<td class=" c73w"><span class="storage"><img src="../../img/storage7.jpg" onmouseout="UnTip()" onmouseover="Tip('Text I want to extract 1 <br/>Text I want to extract 1 )" class="storageBar"><div class="storageLevelDiv"><span onmouseout="UnTip()" onmouseover="Tip('Text I want to extract 1 <br/>Text I want to extract 2')" class="storageLevel">2.966.578</span></div></span></td>
I am trying to read the Tips basically. I know how to crop them and replace whatever I don't need, I also know how to extract the 2.966.578 part, I just can't seem to get the Tooltip.
I've had various tries, here are my last ones, including some thing I found on the forums here and tried out.

Code: Select all

//iimPlayCode("TAG POS=2 TYPE=SPAN ATTR=CLASS:storageLevel&&ONMOUSEOVER:Tip EXTRACT=TXT");
	//iimPlayCode("TAG POS=1 TYPE=TD ATTR=CLASS:onmouseover* EXTRACT=TXT");
	//iimPlayCode("TAG POS=7 TYPE=TD ATTR=CLASS:c73w:storageLevel&&ONMOUSEOVER:Tip EXTRACT=TXT");
	//iimPlayCode("TAG POS=7 TYPE=TD ATTR=CLASS:c73w CONTENT=EVENT:MOUSEOVER EXTRACT=TXT");
	//iimPlayCode("TAG POS=7 TYPE=SPAN ATTR=CLASS:c73w:storageLevel&&ONMOUSEOVER:Tip EXTRACT=TXT");
This I also found on the forums here, but building it into above TAGs always gives me an error claiming it was a wrong use of Command:Tag

Code: Select all

	//CONTENT=EVENT:MOUSEOVER
I would really appreciate if anyone could help me out there, how do I extract the Tip?
Thank you for your time and help!

Best regards,
Yurio
Hum, you've put some nice effort in your Thread, but...: CIM...! :mrgreen: And I only answer Threads when FCI is mentioned, like stated in the Forum Rules, which obviously you forgot to read...

I can just say that I had a similar Need for one of my Macros and I never took the time to really dig into it to find a Solution..., until your Thread, so I dug into my own Case and found a Solution which will probably be very applicable to your Case, I think... (Even if I prefer a URL or some Full HTML Saveas of the Page to play with it myself, as I am not really "fluent" at reading HTML Source Codes, but yours is very similar to mine, so that should work...)

So you mention your FCI and I'll answer your Thread... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
ZmanZoo
Posts: 21
Joined: Mon Feb 16, 2015 8:24 pm

Re: Extracting Tooltip from Onmouseover

Post by ZmanZoo » Tue Apr 07, 2015 4:42 pm

have you looked at http://wiki.imacros.net/TAG#The_EXTRACT_Parameter

which mentions something about
TITLE The title attribute of an element, e.g. the tooltip text.

on the same page theres a part about mouseover events with 3 'notes' that might steer you in the right direction also..
Yurio
Posts: 3
Joined: Mon Apr 06, 2015 9:16 pm

Re: Extracting Tooltip from Onmouseover

Post by Yurio » Thu Apr 09, 2015 9:12 pm

Hello again,

I don't know what FCI is and I couldn't find it out, either.. but I did find out what CIM stands for. I'm sorry, I jumped to conclusions and just figured I'd create a thread, my bad. Let me just roll that up then :)


1. What version of iMacros are you using?
VERSION BUILD=8920312 RECORDER=FX

2. What operating system are you using? (please also specify language)
Windows 7 Ultimate x64

3. Which browser(s) are you using? (include version numbers)
Firefox 37.0.1

4. Do the included demo macros work ok?
Yes and a lot of other Macros I already wrote (both .js and .iim), too

(5. If reporting a problem with the Scripting Interface, please also test if the included VBS sample scripts run ok.
has nothing to do with me I believe)

Website: It's a website that requires a login, that's why I figured I'd just post the corresponding source code, explain it, explain what I got so far, what I tried so far and what I need.

Browser: Since my post was about data extraction, I decided to ask my question in this sub-forum, not in the Firefox one. However it is specifically about Firefox, since I only use that Browser and do not have the alternative of switching over to another Browser just for one Macro. I hope that's understandable.


ZmanZoo wrote:have you looked at http://wiki.imacros.net/TAG#The_EXTRACT_Parameter

which mentions something about
TITLE The title attribute of an element, e.g. the tooltip text.

on the same page theres a part about mouseover events with 3 'notes' that might steer you in the right direction also..
I have indeed checked that already and it got me far, but not to my goal yet.
Two things.
a) Since the thing I wanna extract is already accessable in the source code, I thought it would work without a triggered event.
b) Every single time I replayed one of my attempts, I also made sure to hover over the element just to make sure the respective Tooltip pops up, trying to see if I do have to issue a mouse event or a trigger, but it didn't work like that either. If I found my macro working when I mouseover the element, I would have tried my luck on the trigger simulation.

I believe I just don't have the syntax right, but my attempts were already pretty close to what I would actually have to do. I really hope that you guys can help me with that. I, too, will try to keep working on it and if I find a solution, I will make sure to share my success!

Best regards,
Yurio
Yurio
Posts: 3
Joined: Mon Apr 06, 2015 9:16 pm

Re: Extracting Tooltip from Onmouseover

Post by Yurio » Thu Apr 09, 2015 9:40 pm

I got a temporary solution now by extracting the entire HTM code and cropping it.
Even though I extracted that code more often already, I didn't realize I might as well just cut it to the part that I need. However that is not the perfect solution because the values always change and in this specific case I will most likely not be able to use it. I will however keep working on that and if anyone finds a suitable solution for that, I will be open for news!
chivracq
Posts: 9507
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extracting Tooltip from Onmouseover

Post by chivracq » Thu Apr 09, 2015 11:10 pm

Yurio wrote:I got a temporary solution now by extracting the entire HTM code and cropping it.
Even though I extracted that code more often already, I didn't realize I might as well just cut it to the part that I need. However that is not the perfect solution because the values always change and in this specific case I will most likely not be able to use it. I will however keep working on that and if anyone finds a suitable solution for that, I will be open for news!
Yep, CIM = Config Info Missing and FCI = Full Config Info...
=> iMacros for FF v8.9.2, FF v37.0.1, Win7 Ultimate x32/x64(?)...

But, very good, the HTM Extract is indeed the Solution I implemented for my own Macro, with the HTML Structure of my Page made of TD>DIV>DIV>DIV, I just extract the most Inner DIV to retrieve as little Data as possible though still containing the Data I'm interested in.

In your Case, the HTML Structure of your Page is TD>SPAN>DIV>SPAN, you don't mention on which Element you issued your Extract, I would do it on the most Inner SPAN or the DIV as you get there for each one the 2 Text Parts that you want to extract with stg like this:

Code: Select all

TAG POS=1 TYPE=SPAN ATTR=CLASS:"storageLevel" EXTRACT=HTM
which will retrieve:

Code: Select all

<span onmouseout="UnTip()" onmouseover="Tip('Text I want to extract 1 <br/>Text I want to extract 2')" class="storageLevel">2.966.578</span></div></span>
or:

Code: Select all

TAG POS=1 TYPE=DIV ATTR=CLASS:"storageLevelDiv" EXTRACT=HTM
which will retrieve:

Code: Select all

<div class="storageLevelDiv"><span onmouseout="UnTip()" onmouseover="Tip('Text I want to extract 1 <br/>Text I want to extract 2')" class="storageLevel">2.966.578</span></div>
You may have to tweak the POS=1 into POS=2/3/4 etc... until you locate the correct POS and you may want to use Relative Positioning to locate it more easily... And you choose between the SPAN or the DIV depending on which one is the easiest to locate... And you should actually not stop at POS=1 but try all POS=2/3/4 etc until you get "#EANF#" or some irrelevant Data to identify which Element will return as little Data as possible...

And from your extracted Data, you then use 'EVAL()' with 'split()' (or any other JavaScript String Manipulation Functions) to isolate and only keep the specific Data you are interested in... It doesn't look that complicated in your Case compared to the Site I'm dealing with...

Upload a Full HTML Saveas of your Page (zipped) to your Thread if you don't come out by yourself...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply