Trim/replace/split extracted htm Before and After.

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

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.

Trim/replace/split extracted htm Before and After.

by savefilez on Wed Jan 13, 2016 5:37 pm

Hello,

I'm having trouble trimming/replacing or splitting extracted html, I have tried every code from the forum and nothing seems to be working. I need to get "Limited stock available." and replace the text if found with a 1 for csv saving. I was able to remove everything after "available." but have no idea how to remove all text before "Limited". what's the current way to do this?

TAG POS=1 TYPE=DIV ATTR=CLASS:notices<SP>clear<SP>clearfix EXTRACT=HTM
SET !VAR2 EVAL("var s=\"{{!VAR1}}\"; s.split(\" (\", 1);")
PROMPT {{!VAR2}}

<div class="notices clear clearfix" style="border: 1px solid blue; border-image: none;" oldBorder="undefined"> <a class="notice save" aria-describedby="qtip-0" href="#" data-content='Buy <em class="placeholder">6</em> of this item for $<em class="placeholder">4.77</em> each' data-hasqtip="0"><span class="sprite sprite-save"></span></a> <a class="notice av un" aria-describedby="qtip-1" href="#" data-content='<div>Limited stock available. (0)<br/><br/> Inventory levels fluctuate throughout the day as products are being received and shipped. Contact your Customer Service Specialist for further availablity.</div><div style="margin: 2px 0; padding: 3px 8px; font-weight: bold; color: #FFF; background-color: #8A3C18;">Availability outside of your region</div><div><span style="display: inline-block; width: 225px; padding: 0 8px;">Portland, OR:</span> <span style="display:inline-block;width:10px;height:10px;background-color:#0F0"></span></div><div><span style="display: inline-block; width: 225px; padding: 0 8px;">Denver, CO:</span> <span style="display:inline-block;width:10px;height:10px;background-color:#0F0"></span></div><div><span style="display: inline-block; width: 225px; padding: 0 8px;">Fairless Hills, PA:</span> <span style="display:inline-block;width:10px;height:10px;background-color:#0F0"></span></div><div style="margin: 2px 0; padding: 2px; height: 2px; background-color: #8A3C18;"></div><div style="font-size: 10px; padding: 0 8px;">Fulfillment from outside of your region may incur additional freight charges. Please contact your Customer Service Specialist for assistance.</div>' data-hasqtip="1"><span class="sprite sprite-oos"></span></a> </div>


iMacros Browser (x86) Version 10.4.28.1074
IE 11
Windows 8.1
savefilez
 
Posts: 4
Joined: Sat Jan 09, 2016 8:49 am

Re: Trim/replace/split extracted htm Before and After.

by chivracq on Wed Jan 13, 2016 11:16 pm

savefilez wrote:
Code: Select all
iMacros Browser (x86) Version 10.4.28.1074
IE 11
Windows 8.1

Hello,

I'm having trouble trimming/replacing or splitting extracted html, I have tried every code from the forum and nothing seems to be working. I need to get "Limited stock available." and replace the text if found with a 1 for csv saving. I was able to remove everything after "available." but have no idea how to remove all text before "Limited". what's the current way to do this?

Code: Select all
TAG POS=1 TYPE=DIV ATTR=CLASS:notices<SP>clear<SP>clearfix EXTRACT=HTM
SET !VAR2 EVAL("var s=\"{{!VAR1}}\"; s.split(\" (\", 1);")
PROMPT {{!VAR2}}


Code: Select all
<div class="notices clear clearfix" style="border: 1px solid blue; border-image: none;" oldBorder="undefined">                             <a class="notice save" aria-describedby="qtip-0" href="#" data-content='Buy <em class="placeholder">6</em> of this item for $<em class="placeholder">4.77</em> each' data-hasqtip="0"><span class="sprite sprite-save"></span></a>                            <a class="notice av un" aria-describedby="qtip-1" href="#" data-content='<div>[b]Limited stock available.[/b] (0)<br/><br/> Inventory levels fluctuate throughout the day as products are being received and shipped.  Contact your Customer Service Specialist for further availablity.</div><div style="margin: 2px 0; padding: 3px 8px; font-weight: bold; color: #FFF; background-color: #8A3C18;">Availability outside of your region</div><div><span style="display: inline-block; width: 225px; padding: 0 8px;">Portland, OR:</span> <span style="display:inline-block;width:10px;height:10px;background-color:#0F0"></span></div><div><span style="display: inline-block; width: 225px; padding: 0 8px;">Denver, CO:</span> <span style="display:inline-block;width:10px;height:10px;background-color:#0F0"></span></div><div><span style="display: inline-block; width: 225px; padding: 0 8px;">Fairless Hills, PA:</span> <span style="display:inline-block;width:10px;height:10px;background-color:#0F0"></span></div><div style="margin: 2px 0; padding: 2px; height: 2px; background-color: #8A3C18;"></div><div style="font-size: 10px; padding: 0 8px;">Fulfillment from outside of your region may incur additional freight charges. Please contact your Customer Service Specialist for assistance.</div>' data-hasqtip="1"><span class="sprite sprite-oos"></span></a>                    </div>[/quote]

No URL posted so I won't really do any Testing for you... => Quick Reading for me (but Compliment that you mention your FCI) and I would just want to say that there are 2 Syntaxes for 'split()', => search my Posts on "EVAL + split" for Examples... :idea:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 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: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Trim/replace/split extracted htm Before and After.

by savefilez on Thu Jan 14, 2016 3:12 pm

I did read some of your posts but found nothing. I figured out how to remove everything after available with split but would like to remove everything before Limited. website is password protected. :(
savefilez
 
Posts: 4
Joined: Sat Jan 09, 2016 8:49 am

Re: Trim/replace/split extracted htm Before and After.

by chivracq on Thu Jan 14, 2016 5:18 pm

savefilez wrote:I did read some of your posts but found nothing. I figured out how to remove everything after available with split but would like to remove everything before Limited. website is password protected. :(

Yep, for keeping Data "after", you need to use the "other" Syntax for 'split()'...

I don't know how you searched the Forum, but with the Search I mentioned, the first Hit already gives you a valid Example... (+ Nr 8 as well).
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 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: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Trim/replace/split extracted htm Before and After.

by savefilez on Fri Jan 15, 2016 8:45 am

ok did search EVAL + split, 6 pages long almost all of them saying to use search and some I can't even understand, can you please tell me so I can better understand what I'm doing or searching for.

SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; s.split(\" (\", 1);") removes everything after available. What's the secret Syntax to remove everything before Limited.

<div class="notices clear clearfix" style="border: 1px solid blue; border-image: none;" oldBorder="undefined"> <a class="notice save" aria-describedby="qtip-0" href="#" data-content='Buy <em class="placeholder">6</em> of this item for $<em class="placeholder">4.77</em> each' data-hasqtip="0"><span class="sprite sprite-save"></span></a> <a class="notice av un" aria-describedby="qtip-1" href="#" data-content='<div>[b]Limited stock available.
savefilez
 
Posts: 4
Joined: Sat Jan 09, 2016 8:49 am

Re: Trim/replace/split extracted htm Before and After.

by savefilez on Fri Jan 15, 2016 10:09 am

nevermind I figured it out..

!VAR2 EVAL("var s=\"{{!EXTRACT}}\"; s.split(\" (\", 1);")
SET !VAR2 EVAL("var s = \"{{!VAR2}}\"; var parts = s.split('data-content=\\'<div>'); parts[1];")
savefilez
 
Posts: 4
Joined: Sat Jan 09, 2016 8:49 am

Re: Trim/replace/split extracted htm Before and After.

by chivracq on Fri Jan 15, 2016 1:55 pm

savefilez wrote:ok did search EVAL + split, 6 pages long almost all of them saying to use search and some I can't even understand, can you please tell me so I can better understand what I'm doing or searching for.

SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; s.split(\" (\", 1);") removes everything after available. What's the secret Syntax to remove everything before Limited.

<div class="notices clear clearfix" style="border: 1px solid blue; border-image: none;" oldBorder="undefined"> <a class="notice save" aria-describedby="qtip-0" href="#" data-content='Buy <em class="placeholder">6</em> of this item for $<em class="placeholder">4.77</em> each' data-hasqtip="0"><span class="sprite sprite-save"></span></a> <a class="notice av un" aria-describedby="qtip-1" href="#" data-content='<div>[b]Limited stock available.

savefilez wrote:nevermind I figured it out..

!VAR2 EVAL("var s=\"{{!EXTRACT}}\"; s.split(\" (\", 1);")
SET !VAR2 EVAL("var s = \"{{!VAR2}}\"; var parts = s.split('data-content=\\'<div>'); parts[1];")

Yep, very good, from the first Result Hit like I said, you don't need to go through 6 Pages if I say it's the first Hit... well, the second now, because of your Thread... But nice of you to share your Solution...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 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: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Data Extraction and Web Screen Scraping

Who is online

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

-->