Jump to content
UBot Underground

How to add a constant to a list?


Recommended Posts

HI,

I am actually creating a bot which scrapes a page and before the page scrape starts I have

put a "search page" command to search for a certain element on the page.

 

What I want is that if that element is not on the page, then 0 (zero) should be added to the list

where the rest of the scraped results are added.

 

So, how am I supposed to do that. I am not sure which command should be used to do that.

 

One more question.

I am using a loop to scrape these results.

and I want it to loop for the number of items in a list.

So, I have chosen the number of cycles of the loop using the "List total"

command. So, say the list has 50 items, the bot will loop 50 times.

What I want to know is, will that be enough to control the number of loops

or do I have to give a separate command to stop the bot?

 

Faraz

Link to post
Share on other sites

Hi Faraz,

 

I am actually creating a bot which scrapes a page and before the page scrape starts I have

put a "search page" command to search for a certain element on the page.

 

What I want is that if that element is not on the page, then 0 (zero) should be added to the list

where the rest of the scraped results are added.

Use the $add to list command:

 

if
$search page ("myText")
then
$add to list (myElement)
else
$add to list (0)

 

 

So, I have chosen the number of cycles of the loop using the "List total"

command. So, say the list has 50 items, the bot will loop 50 times.

What I want to know is, will that be enough to control the number of loops

or do I have to give a separate command to stop the bot?

The $list total will do the job Ok. No other command is required.

Link to post
Share on other sites

HI,

I am actually creating a bot which scrapes a page and before the page scrape starts I have

put a "search page" command to search for a certain element on the page.

 

What I want is that if that element is not on the page, then 0 (zero) should be added to the list

where the rest of the scraped results are added.

 

So, how am I supposed to do that. I am not sure which command should be used to do that.

 

Faraz

 

Sounds like you need the if then else command

If search page "whatever"

Then add to list -constant

Else-do something else that does not involve adding anything to a list.

 

or delete else all together.

 

Its up to you.

Link to post
Share on other sites

Sounds like you need the if then else command

If search page "whatever"

Then add to list -constant

Else-do something else that does not involve adding anything to a list.

 

or delete else all together.

 

Its up to you.

 

Well, I am already using the if then else command, but I dont know how to add the zero.

 

As you said:

If search page "whatever" ----------------- I have already done this

Then add to list -constant ------------------- I dont know how to add the constant(which is zero) to the list

 

So, how do I do that?

Link to post
Share on other sites

Well, I am already using the if then else command, but I dont know how to add the zero.

 

As you said:

If search page "whatever" ----------------- I have already done this

Then add to list -constant ------------------- I dont know how to add the constant(which is zero) to the list

 

So, how do I do that?

 

Ok, so you want to add the value zero or a constant as in a ubot constant, or nothing at all?

Link to post
Share on other sites

 

$add to list (0)

[/code]

 

 

 

The $list total will do the job Ok. No other command is required.

 

Ah,Thanks.

I used this one and it worked.

 

Just one more problem.

I have created a loop to get this to work.

And I have chosen the "list total" command to choose the number of times, the bot loops.

 

But, now I find a message which says that the range has exceeded list total.

So, what can I do about this.

Link to post
Share on other sites

It's likely to be a problem with your code, where you are trying to access an list item that's not in the list.

 

Can you post a screen shot of the loop?

 

 

Here's the actual error that I am receiving:

 

you have exceeded the range of the list.

 

command: $next list item

Link to post
Share on other sites

Hi faraz. Go under the variable commands and grab the set list position command. You need to set the list position for that list you are using to zero

 

Okay, I did that and it keeps repeating the same item again and again.

Link to post
Share on other sites

Okay, I did that and it keeps repeating the same item again and again.

And your list is populated by more than one item right? Really wish I could send you an example. . .

The set list position should just allow you to loop without that range error, not repeat the same item over and over.

Link to post
Share on other sites

And your list is populated by more than one item right? Really wish I could send you an example. . .

The set list position should just allow you to loop without that range error, not repeat the same item over and over.

 

Where exactly do I put the set list position command.

should I put it outside the loop or inside it.

I had put it inside the loop just below where I choose the number of loops command.

Link to post
Share on other sites

1. At the very beginning of the script, do

clear list > %keyword list

clear list > %competition

 

2. After the add to list > %keyword list, do a set list posiiton (0).

 

3. Move the sub: google results scraping out of the loop, and to the end of the script.

 

Let us know how you get on.

Link to post
Share on other sites

Correct me if I am wrong but you are trying to increase the size of the list WHILE you are in a looping situation. Right?

 

If that is the case then you are setting yourself up for an infinite loop in the event you do not set the logic up correctly.

 

LillyT's suggestion about using the list position is a good one. But here is what I am wondering. I doubt seriously that you can increase that list's size while the Loop that you are in has that list's amount when you first went into it.

 

As far as modifying the List's total record count while in a Loop using that original total is probably a question best left up to Seth.

Link to post
Share on other sites

1. At the very beginning of the script, do

clear list > %keyword list

clear list > %competition

 

2. After the add to list > %keyword list, do a set list posiiton (0).

 

3. Move the sub: google results scraping out of the loop, and to the end of the script.

 

Let us know how you get on.

 

 

Well, I dont this I should be clearing the lists, because then how will the loop work the 2nd time,

if the list is cleared.

and how will I save the competition list, if I clear it each time.

 

I moved the sub google results scrape out of the loop and when I check the competition txt file,

it is just showing the list result where the bot came to a stop, although it stopped when the list ended.

so that part is working now.

Link to post
Share on other sites

Correct me if I am wrong but you are trying to increase the size of the list WHILE you are in a looping situation. Right?

 

If that is the case then you are setting yourself up for an infinite loop in the event you do not set the logic up correctly.

 

LillyT's suggestion about using the list position is a good one. But here is what I am wondering. I doubt seriously that you can increase that list's size while the Loop that you are in has that list's amount when you first went into it.

 

As far as modifying the List's total record count while in a Loop using that original total is probably a question best left up to Seth.

 

Well, no! I am not trying to increase the size of the list.

there is one list which I am using to set the number of loops.i.e the keyword list.

so, if the keyword list has 50 items, there should be 5 loops.

and each time the loop happens the bot scrapes a page and adds the result to a list.

 

so, when the bot stops, there should be 50 results in the scraped list.

 

Hope this is clear now.

Link to post
Share on other sites

Try the bot in post #17, mate.

 

Wow,Its working perfectly now.

 

Can you tell me what was wrong with the bot I created?

Want to make sure this kind of things doesnt happen again.

 

Please explain the logic of the "clear list" command.

I just dont get it, how it is working if I am clearing the list.

 

And one more thing.

The results I am getting have ,'s in them. eg, 63,20,000 or 20,000

so how do I remove those ,s . but keep in mind that there will be certain results without ,s such as

260 or 2 or 790.

 

Anyways, I have to go to be bed now. Its about 1:30 am in my part of the world.

 

Thanks.

Will read your answer when I get up.

 

Bye,

And thanks again everyone.

Link to post
Share on other sites

Wow,Its working perfectly now.

Great!

 

Can you tell me what was wrong with the bot I created?

Yes, read post #16 through.

 

Please explain the logic of the "clear list" command.

I just dont get it, how it is working if I am clearing the list.

We are clearing the list before the loop.

 

The results I am getting have ,'s in them. eg, 63,20,000 or 20,000

so how do I remove those ,s . but keep in mind that there will be certain results without ,s such as

260 or 2 or 790.

You could use the text command > $replace > ,
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...