0

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]>
2
  • What type of object is Thesaurus? Have you tried doing help(Thesaurus) or dir(Thesaurus) or something similar? Commented Jul 25, 2012 at 16:04
  • @GordonBailey sr2222 answered my question below I left out a very important line in the requesets.get function. Thanks for the response Commented Jul 25, 2012 at 16:08

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Oh I am an idiot! I have 5 other requests.get() functions in my code and they're all the correct syntax and I still couldn't see my error! Thanks for pointing that out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.