Extension that retrieve the html content of an http request - request


#1

Hi,
another request.

I wish to create a block that allow me to get the HTML content of a web page (passing the URL as parameter)

Something like

that return a string with the html of the URL’s page.

Is it possible ?

Thanks


#2

Hi,

mBlock is an open platform. You are welcomed to create extensions by yourself, and it’s not difficult!

Here’s a tutorial for creating a mBlock extension.


#3

Nice to know! But, unluckily, I did not manage to write a working extension for that!
I tried to clone the sample extension and added some
$.ajax({
type: “GET”,
url: “http://…”,
success: function(data) {},
error: function(jqxhr, textStatus, error) {}
});

according to https://www.slideshare.net/DarrenAdkinson/understanding-scratch-extensions-with-javascript-part-2-of-2

But I experience two problems:

  • first, and major, nothing is called on http
  • second: the behaviour changes (the instructions hang) if the mblock ide is connected to serial. actually serial connection should not matter with http…

have you any additional information you can share on this subject to help me moving on?

My regards
Virgilio


#4

Hello virivigio,
This is quite old post and bigeyex is not here. Could you be more specific of your question?
And right now we have mBlock 5 and users can also write extension for mBlock 5.


#5

Hi Tech Support
I have this drone https://www.dji-store.it/tello/ which comes with an extension for Scratch 2 Offline Editor. The extension basically uses the Http Experimental port to talk with a service on http. The drone itself is on udp/tcp on the local wifi network.
I was interested in having the drone work in mblock. Either 3.x or 5.x. But I’m lacking a tutorial on this kind of connections. Many many examples are on serial devices you know. And I also had a couple of tries, actually more than a couple, but “nothing happens” and getting debug information is quite though

Do you have any suggestion?
My regards
Virgilio


#6

Sorry, I am afraid I am not very understand. For the extension, bigeyex had offered guidance we have on mBlock 3 and for mBlock, we have this:https://www.mblock.cc/doc/en/developer-documentation/developer-documentation.html
You mentioned that examples are serial devices, so how would you like to connect your own device to mBlock 3/5?


#7

Thank you, I’ll try to be as clear as I can: I want to write an extension that makes http calls instead of device.write calls. Is it possible?

My regards
Virgilio


#8

Hi virivigio,
Thank you for your concern. I am afraid there is no exact example for your reference. Currently we support connection include: serial, Bluetooth, 2.4G and HID. In a near future, we will support wifi connection. Also we plan to support tello.


#9

There is an extension:
Web Request Extension