Jump to content
UBot Underground

Get Api Data With Ubot (Easy, Free, Script)


Recommended Posts

Hey There  :D

 

After a lot of time investigating how things work with ubot, i got finally results regarding pulling out some data from APIs. The goal was, to get json data from APIs, saving it in a list, variable, table, etc. - without buying an extra Plugin.

I want to use several APIs to build some SEO Tools for myself, automating my workflow. With ubot, this is an easy task now.

 

Starting point was a free API call from omdbapi.com:

http://www.omdbapi.com/?apikey=c388d03c&s=hello

 

I am a #nocoder, but i do have some basic knowledge how things work regarding regex, structuring data and so on.

Of course, this is a "quite quick n dirty" solution, but it delivers results.

 

The Ubot Code

navigate("http://www.omdbapi.com/?apikey=c388d03c&s=hello","Wait")
set(#json,"
{$scrape attribute(<tagname="html">,"innertext")}","Global")
set(#objects,$plugin function("JSONpath.dll", "$JSONpath parser", #json, "$.Search[*].Title"),"Global")
add list to list(%titles,$list from text(#objects,$new line),"Delete","Global")

What is that code doing?

  1. Call an API (in this case a free movie database)
  2. Scrape the response json data into a variable -> #json
  3. Use jpath to filter out the titles into a single variable  -> #objects (somehow it can not be scraped into a list directly, might be another ubotX bug?)
  4. Create a list from that variable -> %titles

 

Tools i used to get there

The free jsonpath plugin from Aymen:
http://network.ubotstudio.com/forum/index.php/topic/16166-free-plugin-jsonpath-parser-plugin/?p=93802

 

A free jpath Builder i used:

http://jsonpathfinder.com/(It is a bit tricky, as you need to tweak it a bit)

 

 

Not familiar with tweaking stuff?

If you do not have enough basic knowledge to tweak the jpath as you need, maybe the JSON PATH BUILDER from Dan ($27) will be a better solution for you:

https://network.ubotstudio.com/forum/index.php/topic/18304-sell-json-path-builder/

I did not check it out yet - but it looks awesome easy. Huge time saver, tiny price.

Plus he is offering a lot of free plugins on his website, so be sure to sneak over there. 

 

 

I hope i can help someone with this tiny bit of ubot code and i appreciate all kind of feedback and optimization tips.

 

Btw.: Got not into saving data to tables yet - if someone could post a hint, how to get all data from that call in a table (e.g. with "title", "year" and "type" as headers), that would be ultracool.  B)

 

 

Rock on!

 
  • Like 2
Link to post
Share on other sites

Congrats on figuring this all out  :)

 

Just a couple of things I want to mention, first is that you can use Heopas plugin and use the http get function instead of the browser when working with APIs. This will just return back to you the JSON of the page and it won't have any of the browser overhead.

 

Another thing is that you may not want to post your API keys publically like that. That means anybody can use them. In this case with a free API its less of a concern but still people could use up your daily limit and then you wouldn't be able to use it.

 

And also, Dan is now giving that tool away for free here: https://www.bot-factory.com/main/

Link to post
Share on other sites

Yaaaay - i can answer. (Sometimes i am not able to answer to a post or like a post - i guess bcs of the permissions)

 

 

Thanks a lot for this awesome hint to the heopas http get plugin. I was not aware of a free plugin which does http get - meeegaultra nice!

Works like a charm.

 

About that API, no problem, i only used it for making the example here in the forum, so everybody can try it asap. But yes, i got your point.

 

Thanks again!

 

 

 

For the Readers
Heopas Plugin: 

http://network.ubotstudio.com/forum/index.php/topic/20002-free-heopas-custom-plugin-thread-lock-sqlite-thread-variables-email-ini-clipboard/page-1

 

JPath Builder:

https://www.bot-factory.com/main/(But you need to join the facebook group, in order to get the builder. The link will be in your subscription confirmation email)

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