adohertyd
adohertyd

Reputation: 2689

Get request not returning expected data python

I'm trying to include a list of synonyms for words that a user inputs in my program. I want to send the word to the Big Huge Thesaurus API which returns the data. I'm using the requests module to send the term but the API is only returning the HTTP response code. What I am expecting is a json object that I can extract the synonyms from. Can someone help me with this please?

>>import requests
>>term = 'Big'
>>Thesaurus=requests.get("http://words.bighugelabs.com/api/2/mykey/%s/json" % term, auth=('',''))
>>print Thesaurus

<Response [200]>

Upvotes: 0

Views: 1918

Answers (1)

Silas Ray
Silas Ray

Reputation: 26160

Pretty sure you have to use Thesaurus.content, Thesaurus.text, or Thesaurus.json. requests.get() returns a requests.Response object, and when you print that, it's just doing an implicit string cast, which for this type of object, just returns the response code formatted in the string you are seeing printed here.

Upvotes: 2

Related Questions