get text from html list

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

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.

get text from html list

by ratatouille on Mon Feb 12, 2018 4:34 pm

i am using imacros to get the text of each list item. My html looks like..
Code: Select all
<html>
<div class="group">
<ul id="fruit_list">
   <li class="fruit">
      <a class="etiqueta">potato</a>
   </li>
   <li class="fruit">
      <a class="etiqueta">apple</a>
   </li>
   <li class="fruit">
      <a class="etiqueta">banana</a>
   </li>
   <li class="fruit">
      <a class="etiqueta">orange</a>
   </li>
</ul>
</div>
</html>


i tried with:
Code: Select all
TAG POS=1 TYPE=UL ATTR=ID:fruit_list EXTRACT=HTM
SET neat_list EVAL("var e_s = '{{!EXTRACT}}'; e_s.substring(e_s.indexOf('<li>'), e_s.lastIndexOf('<\\/li>')).replace(/(<li>|<\\/li>)/g, '').replace(/ +/g, ' ');")
PROMPT {{neat_list}}


I want to show my elements in this format:
Potato apple banana orange

But the result is:
<ul style="outline: 1px solid blue;" id="fruit_list"> <li class="order"> <a class="etiqueta">potato</a> </li> <li class="order"> <a class="etiqueta">apple</a> </li> <li class="order"> <a class="etiqueta">banana</a> </li> <li class="order"> <a class="etiqueta">orange</a> </li> </ul>


Can anyone explain how i can show correctly the elements?
ratatouille
 
Posts: 2
Joined: Mon Feb 12, 2018 4:18 pm

Re: get text from html list

by thecoder2012 on Tue Apr 10, 2018 10:47 am

ratatouille wrote:I want to show my elements in this format:
Potato apple banana orange

Two ways possible.

1. With EXTRACT=TXT
Code: Select all
TAG POS=1 TYPE=UL ATTR=ID:fruit_list EXTRACT=TXT
SET neat_list EVAL("var e_s = '{{!EXTRACT}}'; e_s.replace(/\\n/g, ' ').replace(/ +/g, ' ');")
PROMPT {{neat_list}}


2. With EXTRACT=HTM (your way)
Code: Select all
TAG POS=1 TYPE=UL ATTR=ID:fruit_list EXTRACT=HTM
SET neat_list EVAL("var e_s = '{{!EXTRACT}}'; e_s.substring(e_s.indexOf('<li class=\"fruit\">'), e_s.lastIndexOf('<\\/li>')).replace(/(<li class=\"fruit\">|<\\/li>|<a class=\"etiqueta\">|<\\/a>)/g, '').replace(/ +/g, ' ');")
PROMPT {{neat_list}}


ratatouille wrote:Can anyone explain how i can show correctly the elements?

You have used <li class="fruit"> in your html code and NOT only "<li>" but in your imacros is just <li>. Second thing is <a class="etiqueta"> ... </a> but nothing in your imacros and javascript eval code.
Join 9kw.eu Captcha Service now and let your iMacros continue downloads and scripts while you sleep. - Custom iMacros? Contact me!
User avatar
thecoder2012
 
Posts: 212
Joined: Sat Aug 15, 2015 10:14 am
Location: Internet


Return to General Support & Discussions

Who is online

Users browsing this forum: Google [Bot] and 5 guests

-->