Jump to content
UBot Underground

J Bot

Fellow UBotter
  • Content Count

    23
  • Joined

  • Last visited

Posts posted by J Bot

  1. As you mentioned... threads could cause issues.... and if you are dealing with large files, or slow connections, you may well want to do the save in a thread to allow the rest of the bot to 'carry on'.

     

    To ensure that any file dependent functions don't error out because the file save isn't complete, you could use the following:

     

    loop while($not($file exists("{$special folder("Application")}\\content.txt"))) {
        wait(.2)
    }

     

    adjusting the wait time as you see fit.

  2. Your question isn't quite clear to me.  Not sure how you get a list of names 'set up to a button'

     

    In UBot, multiple items are usually stored in lists or tables.  To process them one at a time, you use a Loop command.

    To find out how many items are in a list, you use the $List Total command.

    $list total is often used in the top of the loop to tell it how many times to repeat. (once fore each item in the list)

     

    If you have items already in a list, and you just want it's total, you can't just drag $list total into your script.  You have to drag it into a command which will accept its value like a Set command or a UI Stat Monitor.

     

    Forgive me if I didn't help you at all, but as I said.... wasn't really clear what you were asking.

     

    Edit: one more thing (based on the 'title' of your post)  The following would set a variable to the 'next item' in your list each time you clicked it.

    ui button("Set Next") {
        set(#Next Item$next list item(%usernames), "Global")
    }

     

    No loop required..... $next list item increments automatically each time it is accessed.

  3. In Dev version, I often just edit html in code view.

     

    Out of curiosity, I placed <!-- comment -->  (an html comment) in a non html portion of my bot

    and then switched to node view to see if it would show up.  (wouldn't that be nice)

     

    It did not show up (no big surprise there)

     

    Neither did any of the original code that had been 'below' the comment.

    Everything after the bogus html comment was gone.... Even in code view.

     

    I am curious, but not dumb, so I just closed without saving... no harm done.

     

    Just thought I'd share though in case any of you other cats out there get any unrealistic bright ideas like this.

  4. You should be able to modify that regex by simply adding additional options in the parentheses, eg.

     

    (hours|day|mins)

     

    not certain that nesting works, but you could try it to make the code more flexible....

     

    Edit: tested

    \d\{1,2}\s(min|hour|day|week|month)(\s|s\s)ago

     

    this one should return both singular and plural. 

  5. While grabbing the whole page is easier, I prefer to find the highest level element I HAVE to scrape in order to capture everything I want.  In this case that is a DIV class="s" -- then I run my regex against that.

    The issue is that the nesting structure of the resulting html is inconsistent.

    BOTH instances... (with our without an image) contain the DIV class="f slp"

    The only thing I found to be consistent was the format of the resulting string you are looking for "nn hours ago"

    With a 24 hour search, I did have to allow for Google returning "1 day ago"

    so.... Here ya go.

    navigate("https://www.google.com/#q=open+source+site:youtube.com&tbs=qdr:d", "Wait")
    clear list(%time)
    set(#ResultsOnly, $scrape attribute(<class="s">, "outerhtml"), "Global")
    add list to list(%time, $find regular expression(#ResultsOnly, "\\d\{1,2\}\\s(hours|day)\\sago"), "Don\'t Delete", "Global")
    
  6. Not sure what the benefit of the windows shortcut file is...  you can just use the batch file with your exe.

     

    My batchfile contains a single line and works just fine.

     

     

    "C:\Users\John\Documents\Guild Wars\helloworld.exe" /auto
    pause
     
    I put it in my GW directory just to match your structure which had a space in the path.
     
    If you know that your batch file will be in the same directory as your .exe, you can just use the following format.
     
    .\helloworld.exe /auto
     
    or, if your exe name has spaces in it....
     
    ".\hello world.exe" /auto
  7. It's pretty easy to stop a While loop though.  You can do it by putting a checkbox in the UI and checking it's state.  If you check it the while loop stops.  i prefer using while's when I can for just this reason. 

     

    The following uses a checkbox to set the #StopLoop variable.  If I check the checkbox, the script stops on the next loop.

    define RunLoop {
        set(#Counter, 0, "Global")
        loop while($comparison(#StopLoop, "!=", $true)) {
            wait(3)
            increment(#Counter)
        }
        alert("You allowed this loop to run {#Counter} times
    before you stopped it.")
    }
    

     

    If you do need to use a regular loop however, you could do the following for testing purposes:

    Put your loop in it's own define, with the increment set to 1. 

     

    Call the loop's define commad from a while loop which you can kill any time you want.

    • Like 1
  8. Have you been pasting the code from the d&d builder into a ui html panel or directly into "code view"?

     

    The code you supplied on your first thread was taken from the code view, thats why it had all those back-slashes

     

     

    Just a comment / clarification on darryl's note here.  This pertains to the ui html panel and ui html window commands as well as the browser command, load html.

     

    I like to use notepad ++ (free text editor) to edit my html code. 

     

    You can cut and paste back and forth from a text editor and the Node View html objects in UBot without issue.  No extra \'s are inserted.

     

    However -- If you copy out of Node View to your text editor, make some changes and paste it back, make sure you paste it back in Node View.  Pasting it in Code View will break your bot.

     

    On the other side of the coin, pulling html out of Code View editing it and pasting into Node View will introduce additional \'s in your html which will mess it up as well because off of your "s will be \"s. 

     

    So, if you want to edit your html in an external editor and then paste it back into Ubot.

     

    1.  Always cut and paste from Node View.

    2.  Also, and less obvious... If you referenced any #variables or %lists in your html...

    (ex. We found {#recordcount} records...)

    You can copy them out of Node View but what shows up in your editor is a broken reference to that object.  That's ok. 

     

    Just know than when you paste your edited code back in, you will want to do it in chunks 'around' those objects.

    (ex. paste We found -- paste records...)  Otherwise, you will need to recreate the object references in the UI.

    • Like 1
  9. Comparing code I had written to the google 'search result scrape' in the bot bank and wonder if my code is better or worse (less robust?) and why.  Any comments would be appreciated as I'm still learning (arent' we all?)

     

    Bot Bank on Setting Time Frame: clicking through the 'visible' items

     

    wait for element(<innertext="Search tools">, "", "Appear")
        click(<innertext="Search tools">, "Left Click", "No")
        wait for element($element offset(<class="mn-dwn-arw">, 1), "", "Appear")
        click($element offset(<class="mn-dwn-arw">, 1), "Left Click", "No")
        wait for element(<innertext=#timeframe>, "", "Appear")
        click(<innertext=#timeframe>, "Left Click", "No")
    

     

    My Version: go right to the 'hidden' selector

     

     click(<innerhtml="#timeframe">, "Left Click", "No")
     

     

    Sames goes for setting result count in preferences...  I've seen a 5x loop clicking the image of 100 instead of just using:

     

    change attribute(<name="num">, "value", 100)
    

     

     

     

     

  10. especially when you know it's a fairly easy question that someone knows the answer to and you get an answer in 13 minutes.... Nice.....

     

    It seems I am not so fortunate.  My most recent question currently has 21 views and now replies after 10 hours.  sigh....

  11. I am working on a fairly straight forward bot that will scrape google results.  I have several methods in mind that could get to a results page in the browser and wonder which would be best.

     

    My intent is to sell this bot.

     

    I'm only scraping the titles and URLS, not going into results.

     

    The search query itself is fairly complex (long). I had to trim the original down as google has a 32 word limit on queries.

     

    I want to run the queries specifically against a fixed # of sites using the site: operator in google, so.. run the query multiple times.

     

    I want Google search settings to include 'Safe Search' = ON

    Google Instant = Off (required for more than 10 results)

    Results = 100 (to improve scrape speed?)

     

    Also: After results are returned I go under search tools and change 'any time' to 'last month'

     

    Now, for the question --  which is best? 

     

    1. Do all these settings in the bot each time it runs. 

     

    2. I could do the search and modifiations in a browser, and save the URL of the Google results page, which includes all of the criteria and the modifications and hard code this 'results' url into the bot.

     

    3. I could get the results url as in option 2. but put a link to it on a page in my website, which the bot could scrape when run.  This allows me to update the query without updating the bot.

     

    For 2 and 3, I don't know if this 'saved url' is 'permanent' or if it will stop working in a couple weeks or days.

     

    Any thoughts or similar experiences would be greatly appreciated.

     

     

     

     

     

     

     

     

     

  12. When considering a tool for creating UI HTML Panels for Ubot, didn't look any further than the powerful looking IDE that John uses in his LearnUbot.com videos. It looks to be Microsoft's SharePoint Designer 2007 which is, by the way, FREE and very powerful. Though it doesn't create the cleanest CSS code on it's own (your style's end up being inline) it is user friendly enough.

     

    All your standard HTML and CSS tags are built into the IDE. You type an open '<' and the IDE offers a dropdown with all of your possible html tags in it.

     

    Say you pic div from the drop down list and hit space, again you are offered up all of the possible parameters.

     

    You can do a split window with code up top and wysiwyg on bottom. Grab an element and resize it in the editor and the necessary css style(s) are automatically added to the element up top.

     

    Just google 'download SharePoint designer 2007'

     

    Don't get SharePoint Designer 2010. It requires that you connect to an actual SharePoint site to use it.

     

    One thing I did notice is that SPD 2k7 displays Open File and Save File elements incorrectly. It displays an input box in front of the button. Don't worry though, it displays correctly in ubot after you paste the code in.

    • Like 1
×
×
  • Create New...