Hello,
I am trying to write a program that pulls a webpage and extracts certain text from it. I am using a pattern to extract the text but I cannot figure out how to save the extracted text into a table. Any idea what I am doing wrong? When I debug it says my local variable is nil even after I said it to the event.reponse()
Details: I am using Sublime on a Windows machine
I also attached a screenshot of my current event.response() output
[lua]
local restaurants = {}
local yelpString = “”
–this method tells the program what to do once the website is retrieved
local function networkListener( event )
if ( event.isError ) then
print( "Network error: ", event.response )
else
yelpString = event.response
--loops through the website to find the pattern that extracts restaurant names and prints it out
for i in string.gmatch(yelpString, “(.-)<”) do
table.insert(restaurants, i)
print(i)
end
end
end
– retrieves the website
network.request( “https://www.yelp.com/search?cflt=restaurants&find_loc=Cleveland%2C+OH%2C+US”, “GET”, networkListener )
[/lua]