Hello,

I trying to parse a JSON result sent by Google Custom Search in
web2py. I have the code working in python, but for some reason, it
doesn't work right in web2py and I can't figure out why.

desired output:
----
Title: title_of_the_link
url: URL_of_the_result
----
Title: title_of_the_link
url: URL_of_the_result
----
etc...

here is the python code that works, with just a standard output of the
results

sr = urllib.urlopen(url)
search_results = json.loads(sr.read())
for i in search_results['items']:
    print '---'
    print 'title:', i['title']
    print 'url:', i['link'], '\n'

here is the web2py code with a insert in a db (the db works, so as the
view, the problem is that the information stored is incorrect)

sr = urllib.urlopen(url)
search_results = json.loads(sr.read())
for i in search_results['items']:
            db.results.insert(link_title=i['title'])
            db.results.insert(url=i['link'])

I am not sure how this works in the first place, I debugged the code,
so I know that the loop works, but it won't catch the title and link.

Any help welcome :-)

Reply via email to