Jump to content

Website (http) communication.


Recommended Posts

Bois... i think i finaly got in over my head big time.

I'm working on a script that will work like a interactive cleverbot (because that seams like a good idear after 2020 >.<)

 

I'm trying to make a script that can read the <p>Content</p> tags on my website-

Tho i don't seam to be able to limit it.

Here is the code and sorry for bad english in advance.

 

key http_request_id;
 
default
{
    state_entry()
    {
        http_request_id = llHTTPRequest("https://purge-0.000webhostapp.com/SL.html", [], "");
    }
    
    http_response(key request_id, integer status, list metadata, string body)
    
    {
        if (request_id != http_request_id) return// exit if unknown
 
        vector COLOR_GREEN = <0.0, 1.0, 0.0>;
        float  OPAQUE     = 1.0;
 
        llSetText(body, COLOR_GREEN, OPAQUE);
    }
}

 

Thanks in advance for the help! this forum is the best! :D

Link to the web ofc: https://purge-0.000webhostapp.com/SL.html

~Perg0

Link to post
Share on other sites

i should mention by "limit" i mean that the script litteraly reads the entire HTML code like:

!DOCTYPE html

<head>
<Title> SL </title>

</head>

<Body.....

Link to post
Share on other sites

I don't think there's any way to pick which part of the page you're getting, all you can do is parse it down after you've received the page.

So llSubStringIndex and llGetSubString. You should include some unique strings onto your page so you can reliably search for them in the response.

Alternatively you should create the page itself in such a way that it has no other content besides the text you need. No tags, nothing.

  • Like 2
Link to post
Share on other sites

LSL has a parser for JSON. If you can make your site emit JSON, that's easier to deal with than trying to parse HTML yourself in LSL. What you're trying to do is quite possible, but more work than necessary.

LSL also has something for parsing comma-separated values.

Web pages don't have to be HTML. They can be text/text or text/json, as well as text/html. There are lots of resources available about making web sites do what you want. In general, it's better to make a web site that talks easily to LSL than making LSL to talk to an existing web site. LSL has severe memory and compute limitations, and the language is not well suited to parsing.

Link to post
Share on other sites

Reminds me, I've tried using the Range header with HTTP_CUSTOM_HEADER but it doesn't seem to work right when using a starting range other than 0, like Range,bytes=500-999

Web pages that return 206 with a starting value of 0 return a status of 499 when greater than 0 is used. Other web pages return a status of 200, but the data is from the start of the page.

Anyone successfully use it before?

Link to post
Share on other sites

NGL when the first thing you read from the wiki is:

//all these functions are untested functions that may have some very strange cases were they acd badly or where the comments are wrong
//see them as buggy PSEUDO-code and consider yourself lucky if there are less than 2 wrong counters and 4 bad pointers/names.
//they are more an example and a concept and unlikely fully functional AS IS.

You get sketchy XD.

Tho it looks to have promising offers- i re-downloaded my python 3 aswell as configured a Google-Sheets doc for it. Ontop LSL seams to read the website just fine if i don't post "code" on it.

All in all it looks like 2021 might be a better year, since already now stuff is working better! ^^

Thanks for the help again! imma keep looking into this.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...