Jump to content
UBot Underground

Page scraping in a function?


Recommended Posts

I cannot for the life of me figure out a solution to this, I've actually tried several dozen solutions over the last couple of hours and to no availe =/

 

I have an overall define command used in my program that contains a variable that I need to get to the define function, but it's just not working.

 

Anyone care to offer a solution to this seeing as how a page scrape refuses to work in a define function.

 

define container {
    set(#variable one, $page scrape("<body>", "</body>"), "Local")
define $return function {
        return(#variable one)
    }
}

Edited by okuma31
Link to post
Share on other sites

Make the define a function not a command

 

That's really not an option, my entire program is organized into commands for upkeep.

 

Here's a typical example of what I'm running into...

command()
define command {
    navigate("http://www.google.com/", "Wait")
    change attribute(<name="q">, "value", $rand(2132132, 1321231231321321))
    wait(1)
define $test {
        set(#var, $scrape attribute(<name="q">, "value"), "Local")
        return(#var)
    }
    navigate("http://google.com", "Wait")
    change attribute(<name="q">, "value", $test())
}

Edited by okuma31
Link to post
Share on other sites


define $container {
set(#variable one, $page scrape("<body>", "</body>"), "Local")
return(#variable one)
}
navigate("http://ubotsandbox.com/radio-buttons.php", "Wait")
set(#returnedcontainer, $container(), "Global")

 

Link to post
Share on other sites

Thanks man that worked, but after testing here's the issue I'm running into.

 

It appears that when I navigate to a new web page it drops the returns value, is there a workaround for this? I'd like to keep the scraping command as is if possible, it's quite a bit of code to copy and paste in every location it's neccessary.

ui save file("save location", #save)
command()
define command {
    navigate("http://www.google.com/", "Wait")
    change attribute(<name="q">, "value", $rand(2132132, 1321231231321321))
    wait(1)
define $test {
        set(#var, $scrape attribute(<name="q">, "value"), "Local")
        return(#var)
    }
    navigate("http://google.com", "Wait")
    scraping()
}
define scraping {
    add item to list(%list, $test(), "Delete", "Local")
    save to file(#save, %list)
}

Edited by okuma31
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...