• Grabbing results from a webpage

    From The Lizard Master@VERT/NITEEYES to All on Thu Jul 23 00:49:29 2020
    I'm throwing around an idea that I grab results from a webserver and display them on screen. As in, I control the webcode too and can pass back simple text. I tried looking up some javascript to do this but kept running into issues, especially since 99% of people aren't trying to pass back to a BBS, and then thought to try here.

    Not anything too fancy, I just want to grab text results and display them on the screen. What would be the most direct route to do this?

    Thanks!

    ---TLM

    ---
    þ Synchronet þ Nite Eyes BBS - To make people happy about my tagline everywhere...
  • From The Lizard Master@VERT/NITEEYES to echicken on Thu Jul 23 13:17:20 2020
    Re: Grabbing results from a webpage
    By: echicken to The Lizard Master on Thu Jul 23 2020 09:14 am

    I'm throwing around an idea that I grab results from a webserver and display them on screen. As in, I control the webcode too and can pass back simple text. I tried looking up some javascript to do this but kept running into issues, especially since 99% of people aren't trying to pass back to a BBS, and then thought to try here.

    Not anything too fancy, I just want to grab text results and display them on the screen. What would be the most direct route to do this?

    load('http.js');
    var req = new HTTPRequest();
    var res = req.Get('http://some.web.site/');
    console.putmsg(res);

    Awesome, thanks!

    ---TLM

    ---
    þ Synchronet þ Nite Eyes BBS - To make people happy about my tagline everywhere...
  • From The Lizard Master@VERT/NITEEYES to echicken on Thu Aug 20 09:18:14 2020
    Re: Grabbing results from a webpage
    By: echicken to The Lizard Master on Thu Jul 23 2020 09:14 am

    load('http.js');
    var req = new HTTPRequest();
    var res = req.Get('http://some.web.site/');
    console.putmsg(res);

    This is probably my javascript ignorance, but can I ask how you pass a javascript variable to a url variable? I tried setting it to a complete string that displays correctly, but I get a 400 error response from the server.

    var res = req.Get(fullFormedURLThatWorksCopyPaste);

    I also tried this -

    var res = req.Get('http:///some.web.site/page?variable1=' + variable1);

    THANKS!

    ---TLM

    ---
    þ Synchronet þ Nite Eyes BBS - To make people happy about my tagline everywhere...
  • From echicken@VERT/ECBBS to The Lizard Master on Thu Aug 20 11:44:23 2020
    Re: Grabbing results from a webpage
    By: The Lizard Master to echicken on Thu Aug 20 2020 09:18:14

    This is probably my javascript ignorance, but can I ask how you pass a javascript variable to a url
    variable? I tried setting it to a complete string that displays correctly, but I get a 400 error
    response from the server.

    You can pass in a string, whether it be a variable or a string literal, eg:

    req.Get('https://some.web.site/'); // literal
    var url = 'https://some.web.site/');
    req.Get(url); // variable

    var res = req.Get(fullFormedURLThatWorksCopyPaste);

    Depends on what fullFormedURLThatWorksCopyPaste is.

    I also tried this -

    var res = req.Get('http:///some.web.site/page?variable1=' + variable1);

    As long as variable1 is a string (or a type that will become a string as needed, but that's a whole other topic). And remove that extra slash near the beginning.

    req.Get('http://some.web.site/page?variable1=' + 'some_string');
    var param = 'some_string';
    req.Get('http://some.web.site/page?variable1=' + param);
    var url = 'http://some.web.site/page?variable1=';
    req.Get(url + param);

    and so on.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Tracker1@VERT/TRN to The Lizard Master on Thu Aug 20 10:37:24 2020
    On 8/20/2020 6:18 AM, The Lizard Master wrote:
    Re: Grabbing results from a webpage
    By: echicken to The Lizard Master on Thu Jul 23 2020 09:14 am

    > load('http.js');
    > var req = new HTTPRequest();
    > var res = req.Get('http://some.web.site/');
    > console.putmsg(res);

    This is probably my javascript ignorance, but can I ask how you pass a javascript variable to a url variable? I tried setting it to a complete string that displays correctly, but I get a 400 error response from the server.

    var res = req.Get(fullFormedURLThatWorksCopyPaste);

    I also tried this -

    var res = req.Get('http:///some.web.site/page?variable1=' + variable1);

    var res = req.Get('http:///some.web.site/page?variable1=' + encodeURIComponent(variable1))

    If encodeURIComponent isn't available, use escape

    --
    Michael J. Ryan
    tracker1 +o Roughneck BBS

    ---
    þ Synchronet þ Roughneck BBS - coming back 2/2/20
  • From The Lizard Master@VERT/NITEEYES to Tracker1 on Thu Aug 20 15:34:06 2020
    Re: Re: Grabbing results from a webpage
    By: Tracker1 to The Lizard Master on Thu Aug 20 2020 10:37 am

    var res = req.Get('http:///some.web.site/page?variable1=' + encodeURIComponent(variable1))

    If encodeURIComponent isn't available, use escape

    Yessss, thank you very much, that was the ticket.

    ---TLM

    ---
    þ Synchronet þ Nite Eyes BBS - To make people happy about my tagline everywhere...
  • From The Lizard Master@VERT/NITEEYES to echicken on Thu Aug 20 15:35:23 2020
    Re: Grabbing results from a webpage
    By: echicken to The Lizard Master on Thu Aug 20 2020 11:44 am

    As long as variable1 is a string (or a type that will become a string as needed, but that's a whole other topic). And remove that extra slash near the beginning.

    Thanks for catching that, it was a mistype in the post not in the code.

    req.Get('http://some.web.site/page?variable1=' + 'some_string');

    For a sec I thought this was working, then I checked the log and saw the url variable was 'some_string' hah! Appreciate it very much, a combination of this and encodeURIComponent() got me there.

    MUCH APPRECIATED!

    ---TLM

    ---
    þ Synchronet þ Nite Eyes BBS - To make people happy about my tagline everywhere...