Jump to content
UBot Underground

Error handling ? What are the Best Practices ?


Recommended Posts

Hello Guys,

 

New ubotter here ;-)

Well i'm not a total newbie as i've been programming about 5 years in the past.

 

So far, I'm able to do tons of things with Ubot. However I find myself facing a real issue :

 

how do you handle errors (especially in loops) ?

 

Do give you an idea of what i'm doing and why it's so important :

- I'm going to create a bot (how original ;-) )

- Before this bot can run, i'm doing a "target website" analyzer bot

- This Analyzer Bot will go to about 1K websites, visit a few pages and check if these pages are 'standard'

- By "standard" the bot will just look if the buttons are properly named, the script installed is in the expected language...etc

- The goal is : the analyzer bot gives a list of target URLs where the "posting" bot will run smoothly as the analyzer bot made sure what was needed was properly configured on the target URLs

- This keeps the "posting" bot a lot more simple (in theory at least)

 

However i'm having the following problems :

- Target URLs not responding

- Target URLs with pop-ups or other weird stuff

- Chose choosen by attribute crashing (for many reasons, e.g. target URL not in the proper language so buttons are not named as expected...)

- and many other issues causing the LOOP do crash

 

How can you correctly handle errors so that, if during an iteration of the loop a problem occurs, it will still go to the next target URL to analyze ? (i.e. continue looping)

 

These crashs are annoying because my result TXT file is still empty event if already 50 or 100 target URLs have been successfully analyzed... (it's said in the tutorial to save to file outside the loop)

 

Another thing : how to you know if the "chose chosen by attribute" function was succesfull ? (so far the only solution I found was to do a "search page" before but it's creating tons of annoying embedded IFs in my LOOP)

 

Thanks for any help,

 

Cheers,

Link to post
Share on other sites

Hello Guys,

 

New ubotter here ;-)

Well i'm not a total newbie as i've been programming about 5 years in the past.

 

So far, I'm able to do tons of things with Ubot. However I find myself facing a real issue :

 

how do you handle errors (especially in loops) ?

 

Do give you an idea of what i'm doing and why it's so important :

- I'm going to create a bot (how original ;-) )

- Before this bot can run, i'm doing a "target website" analyzer bot

- This Analyzer Bot will go to about 1K websites, visit a few pages and check if these pages are 'standard'

- By "standard" the bot will just look if the buttons are properly named, the script installed is in the expected language...etc

- The goal is : the analyzer bot gives a list of target URLs where the "posting" bot will run smoothly as the analyzer bot made sure what was needed was properly configured on the target URLs

- This keeps the "posting" bot a lot more simple (in theory at least)

 

However i'm having the following problems :

- Target URLs not responding

- Target URLs with pop-ups or other weird stuff

- Chose choosen by attribute crashing (for many reasons, e.g. target URL not in the proper language so buttons are not named as expected...)

- and many other issues causing the LOOP do crash

 

How can you correctly handle errors so that, if during an iteration of the loop a problem occurs, it will still go to the next target URL to analyze ? (i.e. continue looping)

 

These crashs are annoying because my result TXT file is still empty event if already 50 or 100 target URLs have been successfully analyzed... (it's said in the tutorial to save to file outside the loop)

 

Another thing : how to you know if the "chose chosen by attribute" function was succesfull ? (so far the only solution I found was to do a "search page" before but it's creating tons of annoying embedded IFs in my LOOP)

 

Thanks for any help,

 

Cheers,

 

Welcome Aboard :-)

 

You could turn go to your preferences and uncheck the "Show Errors" check(if they are getting annoying, it's up to you.) You could filter the urls that do not work, remove them from the list before you run them into the loop. If you are getting pop ups, you could go into your preferences in UBot Studio and turn off the pop ups (unless you need it?)

 

The choose by attribute command works if it's able to choose the target you are trying to work with, and click it for you. If the pages are not loading fast enough, you could always add a few seconds Delays or Wait Finishes. There are a host of other tools under the Flow command that you can use to make this a bit smoother.

 

We are definitely aware of how important it is to make debugging more efficient (and not time consuming) and make your bots run a bit smoother, and we are thinking of ways to improve that for everyone.

Link to post
Share on other sites

Hello Lilly !

 

Welcome Aboard :-)

 

You could turn go to your preferences and uncheck the "Show Errors" check(if they are getting annoying, it's up to you.)

I'll look into this, the problem is not that they are displayed but that they are stopping the script.

 

You could filter the urls that do not work, remove them from the list before you run them into the loop.

I definetely CAN'T, that's the whole point of this "analyzer" bot : get me the URLs which could work with the "posting" script.

 

If you are getting pop ups, you could go into your preferences in UBot Studio and turn off the pop ups (unless you need it?)

I'll try

 

The choose by attribute command works if it's able to choose the target you are trying to work with, and click it for you. If the pages are not loading fast enough, you could always add a few seconds Delays or Wait Finishes. There are a host of other tools under the Flow command that you can use to make this a bit smoother.

I already added Delays.

The problem is actually NOT with the "choose by attribute" but with the following "click chosen"... The "choose by attribute didn't chose anything so the "click" is crashing.

 

Any idea ?

 

And is there a way similar to the old 'GOTO' to skip one iteration of the loop in case a crash appears ?

 

Thanks for your help

Link to post
Share on other sites

Let me make a couple point in here.

 

It's a little known fact that the choose by attribute command can actually work as a qualifier, which means you can put it in an if statement and it will return whether or not it was successful in choosing. The click chosen error you received probably happened because it didn't successfully choose anything.

 

You can check to see if the page has loaded correctly usually but using a search page. For instance, you can say something like:

 

If not $search page ("the page cannot be displayed") then do stuff.

 

There isn't really a goto command, but you can generally organize your code in a way that makes them unnecessary, by putting things in if statements, in subs, etc.

Link to post
Share on other sites

It's a little known fact that the choose by attribute command can actually work as a qualifier, which means you can put it in an if statement and it will return whether or not it was successful in choosing

 

Great that's what I need.

 

Most of the time my script crashes because for a reason or another the choose "didn't choose" (most of the time because the attribute as a different name, i'm targeting a plateform with multiple versions and multiple language and the scraping with scrapebox can't tell me if i have a version X or Y or language A or B of the plateform)

 

Thanks for your help i'll try il tomorrow.

Link to post
Share on other sites

That's exactly the magic that I perform on a constant basis. Once I enter into a new page, I do look for the element that I will be working with and place it into an IF statement with a SEARCH PAGE to just make sure all is well. This will cover about 80% of the issues you'll encounter.

 

Oh, learning how to use subroutines and returns will definitely be your friend! ;)

 

Frank

Link to post
Share on other sites

Thanks all.

 

Here is few tips for the next one trying to do what I did. (could be interesting to save it somewhere, i'm not the only one doing this kind of stuff).

 

So the whole point was to go through around 1000 URLs from a given plateform and "analyze them". If buttons are named correctly then save the URLs in a TXT files (i'm also saving the categories from a dropdown for later use). But :

- Sometimes the page is buggy

- Sometimes the owner puts load of crap (javascript popups, ads pops up, sliding ads, "you have to be 18+ to see the page", etc)

- Sometimes the page is not in the correct language so the buttons I need don't have the right attribute.

 

Solutions :

- NEVER navigate with WAIT LOAD = Yes. This event is sometimes not triggered. Instead I used delay = 15 seconds

- Always CLEAR LIST at the beginning of the script

- Each time a "CHOOSE BY ATTRIBUTE" as to take place, include it as a QUALIFIER in an IF (so if it didn't choose anything it won't crash)

- To avoid having to start from scratch, SAVE IN THE LOOP (so in the loop you do : Read list from file. Then you add your scrapped infos to this list, then you save the list in the file again. All takes place in the loop for each iteration of the script)

- For an unknown reason, a few times SAVE TO FILE crash. So INCLUDE it also as a QUALIFIER in an IF

 

I don't know if it's all "best practice" but it's quite bulletproof now. If you think I made any mistake, feel free to correct / comment.

 

Cheers,

Link to post
Share on other sites

BUTTON 1:

IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If

 

Choose by attribute

Click this run this sub or do something

 

DELETE THE Else

 

BUTTON 1: But it has a different name

IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If IF IF If

 

Choose by attribute

Click this run this sub or do something

 

DELETE THE Else

 

I think just about every statement in my registration and link dropping bots is an IF.

 

:)

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...