• Grabbing results from a webpage

    From The Lizard Master@NITEEYES to All on Thursday, July 23, 2020 00:49:29
    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 echicken@ECBBS to The Lizard Master on Thursday, July 23, 2020 09:14:12
    Re: Grabbing results from a webpage
    By: The Lizard Master to All on Thu Jul 23 2020 00:49:29

    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);

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    ■ Synchronet ■ electronic chicken bbs - bbs.electronicchicken.com
  • From The Lizard Master@NITEEYES to echicken on Thursday, July 23, 2020 13:17:20
    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@NITEEYES to echicken on Thursday, August 20, 2020 09:18:14
    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@ECBBS to The Lizard Master on Thursday, August 20, 2020 11:44:23
    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@TRN to The Lizard Master on Thursday, August 20, 2020 10:37:24
    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@NITEEYES to Tracker1 on Thursday, August 20, 2020 15:34:06
    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@NITEEYES to echicken on Thursday, August 20, 2020 15:35:23
    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...