How to retrieve wav file from API? - python

I am working on Python3.4.4
I tried to use a Merriam-Webster API, and here is an example link:
http://www.dictionaryapi.com/api/v1/references/collegiate/xml/purple?key=bf534d02-bf4e-49bc-b43f-37f68a0bf4fd
There is a file under the tag, you will see after you open the url.
And I am wondering that how can I retrieve that wav file......
Because it is kind of just a string to me......
Thank you very much!

Okay, I just sort it out.
Usually you need to look at the instructions for the API, I look it up on the official website and it tells you that how you are going to retrieve that. In this case you are going to another url, and then wala

Related

Sharing files in Google Drive using Python

There are plenty of resources involving sharing files in Google Drive but I can't find anything useful to Python and the references by Google aren't Python-specific.
I've saved an item ID into the variable selected_id. In this case, I want to make that file shareable by URL to anyone for reading.
service.permissions().create(body={"role":"reader", "type":"anyone"}, fileId=selected_id)
This is what I have so far but I don't think I formatted it correctly at all.
Like the title states, how would I share a file by ID on GDrive using Python? Thanks in advance.
Looks like you've got the correct format as per Permissions:Create
Perhaps you just need to add .execute() on the end?
service.permissions().create(body={"role":"reader", "type":"anyone"}, fileId=selected_id).execute()
Also is you're looking for examples using the Python API check out the following repository:
https://github.com/gsuitedevs/python-samples
I would image that you're code might look like something similar to this:
https://github.com/gsuitedevs/python-samples/blob/master/drive/driveapp/main.py#L57

Can I send images back to API.AI?

I've been working on something using API.AI to create a Google Action that will send random web comics when asked. I have tried and tried, but so far it doesn't seem like there is a good way to put the image's bytes into the JSON response required for API.AI. I might have missed something along the way, but if anyone knows how this can be accomplished that would be of great help. I have been using python if that helps.
You can get or put images as a response from Api.ai just put url of that image . Here is some useful docs link :
https://docs.api.ai/docs/rich-messages#image
https://docs.api.ai/docs/query#section-message-objects

Libraries for generating URL of uploading files in Django

Need to develop a project for file uploading and generating its(files's) URL, which could be shared. Are there any particular libraries or simple means in Python,(Django) that would be handy and efficient.?
~ Newbie trying a Herculean Task~ Thanks in Advance :)
Much of this is done for you in the Django-backed version of this excellent JQuery file upload app.
Try out a demo of the original here.
No. Since the Storage used may not even save the actual files on the filesystem, there is no universal way to generate a URL to them. You will need to create a view that gets passed a key that it can use to identify the record that has the file field, then you will need to respond with the file contents yourself.

python-otter documentation

I want to collect old tweets for a specific period. I have found out that topsy provides the Otter API to do that. I am developing in Python so I found the python-otter API http://otterapi.googlecode.com/svn/trunk/. However, there is no documentation and I have no idea how to use it! Does anybody know if there is any documention at all. And btw is there another way I can find old tweets programatically?
Thanks
The documentation can be found in http://code.google.com/p/otterapi/wiki/Resources
Why not directly make GET requests using urllib2 and the like??

Different results for the same RSS feed fetching from different user agents

If I add a feed URL to Google Reader or to a desktop feed aggregator, I receive nice results. The URL is:
http://estaticos03.marca.com/rss/futbol_1adivision.xml
But when I fetch the same URL from a script (python script, using feedparser library) I am getting slightly different content for the same results (the title for each entry, for example, is different and all in uppercase).
I believe something is done on the server-side to try to discourage people like me to parse the content for my own projects (the feed is from a popular football newspaper), but I am not sure about it. I tried to pass some user agents (like the google reader one) but still no luck, so maybe they check the IP as well? I am really confused.
Any idea why is this happening to me?
Thanks!
AFAIK Google Reader does some "magic" in the content to beautify it. They strip some tags and styles to avoid breaking their interface.
Can you provide more details on the differences?
Did you changed the user agent of your script? Try to mimic Firefox and see what happen.
All right folks, I found it. I analyzed the source XML received (as #TryPyPy). I had been trusting too much the feedparser library. Latest official version (4.1) has a bug related to mistakeing the title tag from media namespace instead of the original one:
http://code.google.com/p/feedparser/issues/detail?id=76
So I reinstalled from trunk and now everything is OK. Thanks for helping anyway!

Categories

Resources