Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you get individual lines from a webpage using httpservice?

Asked by 6 years ago

How do I make something like this? For example I give the script this link https://pastebin.com/raw/78VT3MUS it will print:

line1
line2

line4

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You can do this:

local http = game:GetService("HttpService") 
http.HttpEnabled = true 
local page = http:GetAsync("https://pastebin.com/raw/78VT3MUS") 
print(page)

It sets HttpEnabled to true so that it's allowed to get the page, then gets that page with GetAsync.

(You have to turn on HTTP requests in your game settings for it to properly work)

edit: SHOOT I DIDN'T READ THE QUESTION RIGHT TRY THIS:

local lineNumber = 1
local http = game:GetService("HttpService") 
http.HttpEnabled = true 
local page = http:GetAsync("https://pastebin.com/raw/78VT3MUS") 
local function parse(s) -- stole this, sorry ScriptGuider
    local t = {};
    for chunk in string.gmatch(s, "[^\n]+") do
        t[#t+1] = chunk;
    end;
    return t;
end;
local foundPage = parse(page)
print(foundPage[lineNumber]) -- line1
0
I know how to use getasync but how do I get individual lines? SimplyJeremy 8 — 6y
0
yeah you really didn't answer his question DeceptiveCaster 3761 — 6y
0
also, what the hell is http.HttpEnabled? that doesn't work! DeceptiveCaster 3761 — 6y
0
sorry, tried again ihatecars100 502 — 6y
Ad

Answer this question