ul li position for li and data value if empty

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

ul li position for li and data value if empty

by pecnet on Wed May 17, 2017 6:27 am

Hello,

I successfully configured my imacros script to retrieve information,
However I block on 2 levels.

I recieve the description of a product, but on some products there is no description.

I would like to know if I can determine a text by default if there is no description

Ex: No description

TAG POS=1 TYPE=SPAN ATTR=ITEMPROP:description EXTRACT=TXT

Second problem I have an ul with 3 li

Code example

Code: Select all
<ul class="top-breadcrumb" xmlns:v="http://data.sample.org/#">

    <li typeof="v:Breadcrumb" class="top-breadcrumb-home"><a href="#" rel="v:url" property="v:title" class="home">Home</a>
    </li>
   
    <li>
    <a href="url2">Category <i class="fa fa-angle-right" aria-hidden="true"></i></a>
    </li>
   
    <li>
    <a href="url3">Sub category name <i class="fa fa-angle-right" aria-hidden="true"></i></a>
    </li>
   
</ul>


I would like to know how one can recover only the content of the 3rd li?

I use mac os with firefox
Can you please help me?
Thank you
pecnet
 
Posts: 21
Joined: Wed Nov 25, 2015 1:35 pm

Re: ul li position for li and data value if empty

by chivracq on Wed May 17, 2017 4:01 pm

pecnet wrote:Hello,

I successfully configured my imacros script to retrieve information,
However I block on 2 levels.

I recieve the description of a product, but on some products there is no description.

I would like to know if I can determine a text by default if there is no description

Ex: No description
Code: Select all
TAG POS=1 TYPE=SPAN ATTR=ITEMPROP:description EXTRACT=TXT


Second problem I have an ul with 3 li

Code example
Code: Select all
<ul class="top-breadcrumb" xmlns:v="http://data.sample.org/#">

    <li typeof="v:Breadcrumb" class="top-breadcrumb-home"><a href="#" rel="v:url" property="v:title" class="home">Home</a>
    </li>
   
    <li>
    <a href="url2">Category <i class="fa fa-angle-right" aria-hidden="true"></i></a>
    </li>
   
    <li>
    <a href="url3">Sub category name <i class="fa fa-angle-right" aria-hidden="true"></i></a>
    </li>
   
</ul>


I would like to know how one can recover only the content of the 3rd li?

I use mac os with firefox
Can you please help me?
Thank you

CIM...! :mrgreen:
Yeah but sorry I don't read, I'm tired of having to ask you in all but 1 of your (previous) Threads to mention your FCI when you open a Thread... :roll: (Last time I ask, sorry, I won't react to your Threads anymore if mentioning 3 Versions about your Environment is too complicated each time...)

Hum, and I don't see any Script except one 'TAG' Statement and some HTML mini-bit of the Source Code, but no URL, it's much easier to help you if you can post your Script with the URL of the Page (or upload your Page to the Thread if it's behind Login&Password) than having to dig into the HTML Source Code of a Page or having to reconstruct the Page from scratch from that Source Code..., where the 'POS' Numbers then very often don't correspond... or some simpler other Solution like Relative Positioning for example cannot be considered because of the limited Info that a mini-Excerpt of the HTML Source Code offers...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: ul li position for li and data value if empty

by chivracq on Wed May 17, 2017 4:32 pm

OK, I read your Post..., oh! and some limited Info about your FCI is mentioned half hidden in text..., this Info belongs to the top of your Post, completely clear and full with all 3 exact Versions...
=> iMacros for FF v9.0.3...? / v8.9.7...?, FF53...?, MacOS X.

No Script + no URL => generic Answers...!

Qt_1:
Yep, simply use 'EXTRACT' + 'EVAL()'...
But v9.0.3 for FF seems to have a Bug with 'EXTRACT' when the Element is not found, search the Forum for some Thread explaining everything, "best" Solution in short is to revert to v8.9.7.

Qt_2:
Pfff, difficult to answer precisely with the limited/anonymised Info you provide..., but simply use 'POS=3' on the 'CLASS' Attribute of the 'LI' Elements I would think...
If there are other Rows previously on the Page or in the Table, then try tagging the Row on its 'CLASS' Attribute (especially if it's unique, can't tell from your Info) as Anchor for Relative or maybe Relative Positioning to locate the 3rd 'LI' Element...
Tja...!, sorry, generic Answer that you probably won't understand or won't know how to implement because of the generic Level of Info you provide about the Page... :roll:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: ul li position for li and data value if empty

by pecnet on Wed May 17, 2017 10:47 pm

Hello
First sorry if i have not explained my english is very bad i use google translate.

My first problem is resolved with the v8.9.7 version of imacros

Thank you very much.


For my second problem I tried this but I still can not extract the contents of the 3rd li ....

Here is what I tried

Code: Select all
TAG POS=3 TYPE=CLASS ATTR=UL:top-breadcrumb&&TXT:* EXTRACT=TXT


or

Code: Select all
TAG POS=3 TYPE=CLASS ATTR=LI:&&TXT:* EXTRACT=TXT



Thank you very much
Last edited by pecnet on Thu May 18, 2017 3:15 am, edited 1 time in total.
pecnet
 
Posts: 21
Joined: Wed Nov 25, 2015 1:35 pm

Re: ul li position for li and data value if empty

by pecnet on Thu May 18, 2017 2:29 am

Hello again

I understand why you need more information at the html level or to have a link ...

I solved my problem

like this ...



Code: Select all
TAG POS=1 TYPE=DIV ATTR=CLASS:"col-xs-12 col-sm-10 col-md-10 col-lg-10 main_container"
TAG POS=R3 TYPE=LI ATTR=NAME:* EXTRACT=TXT



thanks
pecnet
 
Posts: 21
Joined: Wed Nov 25, 2015 1:35 pm

Re: ul li position for li and data value if empty

by chivracq on Thu May 18, 2017 6:15 am

pecnet wrote:Hello
First sorry if i have not explained my english is very bad i use google translate.

My first problem is resolved with the v8.9.7 version of imacros

Thank you very much.

Yeah but "lack of Info" is not "caused" by "bad English" to mention 3 Versions and post the URL of the Site/Page...

=> OK, you were on v9.0.3 for FF + FF53 y + MacOS X.
And now you are on v8.9.7 for FF + FF53 + MacOS X.

And OK, Qt_1 is solved with v8.9.7 for FF, good...! :D

pecnet wrote:For my second problem I tried this but I still can not extract the contents of the 3rd li ....

Here is what I tried
Code: Select all
TAG POS=3 TYPE=CLASS ATTR=UL:top-breadcrumb&&TXT:* EXTRACT=TXT


or
Code: Select all
TAG POS=3 TYPE=CLASS ATTR=LI:&&TXT:* EXTRACT=TXT


Thank you very much

Yeah but 'UL' and 'LI' are "TYPE"s for 'TAG' Statements, and 'CLASS' is an Attribute ("ATTR"), you've inverted both in your 2 Attempts... Simply look at how iMacros records tagging those Elements (the Cell and the whole Row).

pecnet wrote:Hello again

I understand why you need more information at the html level or to have a link ...

I solved my problem

like this ...
Code: Select all
TAG POS=1 TYPE=DIV ATTR=CLASS:"col-xs-12 col-sm-10 col-md-10 col-lg-10 main_container"
TAG POS=R3 TYPE=LI ATTR=NAME:* EXTRACT=TXT


thanks

Yeah, this is what I meant with Relative Positioning, the 'POS=R3' is good.
I was more thinking of using the 'UL' as Anchor, OK, you managed to find a 'DIV' to use instead, but you were a bit "lucky" I would think, as 'DIV' Elements need "Double Relative Positioning" to be able for iMacros to "see" nested Elements inside them, so your Solution will probably not work anymore if the Structure of the Table(s?) changes a bit and if Rows get added or removed or if the HTML Structure of the Page or of that 'DIV' changes a little bit as its 'CLASS' looks to me like it is defining its Structure.

And I guess the first 'LI' with "class="top-breadcrumb-home"" can probably be used as Anchor as well, I reckon it will always be there and won't change (=> with 'POS=R2' for your 3rd 'LI'...).

But OK, if it works for now, then I guess you're Happy...! :D
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: ul li position for li and data value if empty

by pecnet on Thu May 18, 2017 6:26 am

Thank you for your reply :-)

Can you if possible write your method for me to test?
So I can compare and keep the best ....

thank you
pecnet
 
Posts: 21
Joined: Wed Nov 25, 2015 1:35 pm

Re: ul li position for li and data value if empty

by chivracq on Thu May 18, 2017 7:02 am

pecnet wrote:Thank you for your reply :-)

Can you if possible write your method for me to test?
So I can compare and keep the best ....

thank you

Well, that's a bit difficult without being able to "play" myself with the Page...!

But if 'POS=1' works for finding the Row-Header, then this one should work I would think:
Code: Select all
TAG POS=1 TYPE=LI ATTR=CLASS:"top-breadcrumb-home"&&TXT:Home EXTRACT=TXT
SET !EXTRACT NULL
TAG POS=R2 TYPE=LI ATTR=NAME:* EXTRACT=TXT

You'll need to play with 'POS=2' / '=3' / etc if 'POS=1' doesn't work for the Anchor...
The "fake" 'EXTRACT' on the Anchor is to prevent iMacros from following the Link on 'Home'.
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: ul li position for li and data value if empty

by pecnet on Thu May 18, 2017 7:23 am

Hello
I also tried your solution
It's also good :-)
pecnet
 
Posts: 21
Joined: Wed Nov 25, 2015 1:35 pm

Re: ul li position for li and data value if empty

by chivracq on Thu May 18, 2017 7:35 am

pecnet wrote:Hello
I also tried your solution
It's also good :-)

Oh, good...! Then if "my" Solution works, it's probably more reliable than yours with your 'DIV' as Anchor... :wink:

But if this 'Home' Button is for the Global Navigation on the Site, it is no Standard Practice to use a Table for the HTML Structure of a Site/Page for its Navigation, rather 'DIV' and 'SPAN' Elements, so your Site looks a bit "strange" to me, and there is always a "Risk" that the Site Admin will "modernize" it one day, and you'll have to "rethink" your Script...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: ul li position for li and data value if empty

by pecnet on Thu May 18, 2017 7:41 am

Yes it's strange
For now I know how to retrieve the info I need

When we understand imacros it becomes easier life

:-)
pecnet
 
Posts: 21
Joined: Wed Nov 25, 2015 1:35 pm

Re: ul li position for li and data value if empty

by chivracq on Thu May 18, 2017 8:23 am

pecnet wrote:Yes it's strange
For now I know how to retrieve the info I need

When we understand imacros it becomes easier life

:-)

"When we understand imacros it becomes easier life"
=> Hum..., that will be the Happy Motto of the Day, ah-ah...!! :D
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 5730
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to iMacros for Firefox

Who is online

Users browsing this forum: Bing [Bot] and 9 guests

Website Monitoring