Jump to content
UBot Underground

Finding List Item Position


Recommended Posts

Ok... so I have a list of 10 URLs. I want to parse through the list 10 URLs looking for example.com and when it finds it I want to return its position in the list.

 

Rather than post my failures a few ideas on how you would do this would be great. I've tried the while loop but if it gets to the end of the list before it finds the url it causes and error since there are no more entries in the list. I've also tried a loop with using evaluate but I'm screwing it up somehow.

 

I know this should be simple but I'm missing a step somewhere.

 

TJ

Link to post
Share on other sites

I've uploaded a bot for you that does what I think you're looking for. Let me know if it does what you were looking for.

 

Wow I didn't expect a reply that fast! This is a great community.

 

Thanks man, that's perfect. It does just what I needed and I can see where I messed up. I was complicating things too much and the use of "stop script", I didn't think of.

 

Thanks again.

Link to post
Share on other sites

No problem at all man, glad to help :)

 

(and I agree, this is a great community)

 

One additional issue with this. Can I use wild cards in the evaluate function some how?

 

Basically in my list of 10 URLs scraped from G. There can be slight variations in the ref url. Like http://example.com/ and http://example.com (without the trailing "/"), or even a leading www. could throw it off. Not to mention if the url sometimes contains the pagename as well.

 

So I really just want to check for "#url like example.com" or use *example.com*.

Link to post
Share on other sites

One additional issue with this. Can I use wild cards in the evaluate function some how?

 

Basically in my list of 10 URLs scraped from G. There can be slight variations in the ref url. Like http://example.com/ and http://example.com (without the trailing "/"), or even a leading www. could throw it off. Not to mention if the url sometimes contains the pagename as well.

 

So I really just want to check for "#url like example.com" or use *example.com*.

 

 

That's something I'll have to look into, I don't have an immediate answer for you on that one. I'm thinking it isn't possible based on this thread: http://ubotstudio.com/forum/index.php?/topic/2368-can-you-search-for-text-in-a-variable/

 

I'm thinking you'd have to go through the list with a "loop" function replacing all the things you need to get rid of to do a proper search. I.E.:

 

replace .com/ with .com

replace http://www. with $nothing

replace http:// with $nothing

etc, etc

Link to post
Share on other sites

 

I'm thinking you'd have to go through the list with a "loop" function replacing all the things you need to get rid of to do a proper search. I.E.:

 

replace .com/ with .com

replace http://www. with $nothing

replace http:// with $nothing

etc, etc

 

Hmm that does give me some ideas though thanks. Maybe I can use that combined with the ulibs somehow.

Link to post
Share on other sites
  • 1 year later...

I know this is a very old post but I'm trying to replicate this in ubot version 4 and it's not working for me. I need to be able to go through a list, find an item, and have the bot tell me what position the found item is at. The example bot here works great in ubot version 3 but I can't get it to work in version 4.

 

 

For some reason I can not reply to this thread (getting an error meassage) but I can edit my previous post???

 

Anyway, @ JohnB, yes that makes sense but I'm still doing something wrong and I'm not sure what exactly. For testing I was just using a list of the alphabet from a to z. In the UI I input a letter and when I run the bot it's supposed to return the current list position (the numeric position of the letter I chose) it's just not working though.

 

Here is the code I'm using. If I can figure it out I'm going to make a serp rank tracker because I'm having a lot of issues with Market Samurai right now. :-(

 

 

clear list(%list to search)
ui open file("list to search", #list to search)
ui text box("item to search for", #item to search for)
add item to list(%list to search, $read file(#list to search), "Delete", "Global")
set(#current list position, 0, "Global")
loop($list total(%list to search)) {
   if($comparison($list item(%list to search, #current list position), "=", #item to search for)) {
       then {
           load html(#current list position)
       }
       else {
       }
   }
   increment(#current list position)
}

Link to post
Share on other sites

Adam, if you set a variable outside the loop (i.e. #position) to 0 and increment inside the loop (using that variable as the list position, you will always have a running list position number assigned to that variable. Does that make sense?

 

John

Link to post
Share on other sites

Adam, if you set a variable outside the loop (i.e. #position) to 0 and increment inside the loop (using that variable as the list position, you will always have a running list position number assigned to that variable. Does that make sense?

 

John

 

That makes sense but it's still not working for me. I couldn't post for some reason yesterday but I was able to edit my other post (no idea why) so I pasted in the code that I was working with. Something else must be wrong still, I'm just not sure what it is.

Link to post
Share on other sites

Try this it works for me. You need to use 'add list to list' with ubot4 and 'list from file' rather than 'read file'.

 

 

clear list(%list to search)

ui open file("list to search", #list to search)

add list to list(%list to search, $list from file(#list to search), "Delete", "Global")

ui text box("item to search for", #item to search for)

set(#current list position, 0, "Global")

loop($list total(%list to search)) {

if($comparison($list item(%list to search, #current list position), "=", #item to search for)) {

then {

load html(#current list position)

}

else {

}

}

increment(#current list position)

}

  • Like 4
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...