Hi! I’m trying to learn http.request, and I thought a fun little exercise would be getting certain text. For example, get the text that says “Inbox” on Codea. Is this possible?



Sure http.request is going to return the page source. You can search the returned string and grab what you like. I’m not sure why’d you grab the text inbox but you could.

@Prynok There’s not much code to get “inbox”. But what you do with it might take a lot more.

function setup()

function draw()
    background(40, 40, 50)

function fail(error)

function gotData(data,status,headers)
    for x,y in pairs(headers) do

@dave1707, Thanks, but I already know how to do that. I was asking how to get certain text from the data, and I used the text “Inbox” at the top of the screen as a example. :slight_smile:

@Prynok Sorry, I didn’t understand the exact question. To get any text, a string.find, string.match, etc, would be used to find what you’re after in the data, or header information that you get back. But then you probably know how to use those also.

string.gsub if you plan to replace it with another piece of text

@Prynok - Codea will return the HTML web page. To see what this looks like, load the page in your web browser and view the source (eg in Firefox, look under Tools, Web developer, Page source).

Find what you want there, and figure out what unique text tags you can use to locate it with a text search when it is downloaded. Then use string.find and string.sub to extract it.

No shortcuts, I’m afraid… Every page is different.

@Ignatz Thanks!

@Ignatz Rather than getting the exact position, you could also do string matching to maybe iterate through say, every

tag and extract the text from it.

@Prynok Tutorial-like comment on string matching here.