How to NOT VISIT some links

Discussions and Tech Support specific to the iMacros Firefox add-on.
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
Ironmaidenx
Posts: 3
Joined: Mon Aug 12, 2013 8:08 pm

How to NOT VISIT some links

Post by Ironmaidenx » Fri Aug 16, 2013 12:31 am

Hello Eveybody,

First of all, please excuse me if my english is not that good.

This been a week that i'm trying to figure it out. But i cant find a solution.

I have made a macro that visits 15 profiles in a row on a search page.
Then goes to the next search page.
The profiles change everytime you re-do the research. Basically it's a succession of :

Code: Select all

URL GOTO http://www.domain.com/mySearch?page=n
TAG POS=m TYPE=DIV ATTR=CLASS:mask&&TXT:
n & m varies from 1 to 15

My problem i s that i DONT want to visit some profiles, which are already in "My Contacts". I looked into the source code of the page and this what i get under firefox for a profile which is already in my contacts

Code: Select all

<div class="person large" data-id="555555">
	
	<a href="http://www.domain.com/profile/555555">
		<div class="pic">
			<div class="mask"></div>
			<img src="http://s3.domain.com/fr/5/5/5/5/5/5/5/thumb1_15.jpg" height="100" width="100">
		
			[color=#FF0000]<span class="favicon small">In contact</span>[/color]
			
		</div>
	</a>
	<div class="infos">
		<h4>ProfileName'</h4>
		<span class="city">ProfileCity</span>
		<span class="age">ProfileAge</span>
		<ul class="actions">
			<li class="view"><a href="http://www.domain.com/profile/555555" title="see profile">See profile</a></li>
			
			
			[color=#FF0000]<li class="send-mail"><a href="http://www.domain.com/messages/index/thread/555555" title="send a message">Send a message</a></li>[/color]
			
			
		</ul>
	</div>
</div>
The profiles i'm interested in, got exactly the same code, except for the elements between [ color=#FF0000 ] & [ / color ] which are specific to my contacts

I can give you also the javascript code that generates the page if there is any need for.

Can anyone help me please :) ? Thank you very much
User avatar
bobis
Posts: 364
Joined: Sat Sep 11, 2010 3:34 pm
Contact:

Re: How to NOT VISIT some links

Post by bobis » Fri Aug 16, 2013 7:08 am

load list of your current contacts to array and each time compare it with your current profile before visiting profile.
can be done with js or similar, but not with regular IIM script
Get Best iMacros scripts at http://imacrosbot.com/
Ironmaidenx
Posts: 3
Joined: Mon Aug 12, 2013 8:08 pm

Re: How to NOT VISIT some links

Post by Ironmaidenx » Fri Aug 16, 2013 9:19 am

Its not the optimal solution, as the list of my contacts is also changing

What i need is something that identifies the "incontact" and not visit it, and instead visit the others
User avatar
FoxDot
Posts: 20
Joined: Thu Jun 13, 2013 2:31 pm
Location: Chisinau
Contact:

Re: How to NOT VISIT some links

Post by FoxDot » Fri Aug 16, 2013 10:12 am

As bobis said, you need JS )

I would extract the whole div tag:

Code: Select all

<div class="person large" data-id="555555"> ..... </div>
as HTM and then check if "In contact" string exists in my extraction with indexOf() function, if not exists - with regex strip the href link.

Code: Select all

iimPlay("CODE:TAG POS=1 TYPE=DIV ATTR=CLASS:person<SP>large EXTRACT=HTM");
 if(iimGetLastExtract().indexOf("In contact")<0)
    var visit_url = iimGetLastExtract().replace(/\s/g,"").replace(/(<div.+href=\")|(\".+)/g,"")
in such a way you will skip the profiles that are already in your contacts :)
The Fox Will Find You!
Ironmaidenx
Posts: 3
Joined: Mon Aug 12, 2013 8:08 pm

Re: How to NOT VISIT some links

Post by Ironmaidenx » Sat Aug 17, 2013 12:40 pm

Hello FoxDot !

Thank you very much.

So i did what you told me to do

Code: Select all

iimPlay(macrotest)

iimPlay("CODE:TAG POS=1 TYPE=DIV ATTR=CLASS:person<SP>large EXTRACT=HTM");
 if(iimGetLastExtract().indexOf("In contact")<0)
    var visit_url = iimGetLastExtract().replace(/\s/g,"").replace(/(<div.+href=\")|(\".+)/g,"")

It seems working ! But the problem is that the last line just "tag" the link, and don't visit the page behind it.
User avatar
FoxDot
Posts: 20
Joined: Thu Jun 13, 2013 2:31 pm
Location: Chisinau
Contact:

Re: How to NOT VISIT some links

Post by FoxDot » Mon Aug 19, 2013 12:07 pm

in the last line i'm just storing the link, without visiting it.
To visit the extracted link you should add at the end:

Code: Select all

iimSet("url", visit_url);
iimPlay("CODE:TAB OPEN\nTAB T=2\nURL GOTO={{url}}");
The Fox Will Find You!
Post Reply