get twitter feed (R or python) - python

I used to get twitter data using R with an xml package. Seems like they no longer use xmls and only use json. I tried a few methodologies with json and I keep getting an error saying API 1.0 not available anymore and I need to use API 1.1. Fine but there seems to be no clear documentation in how to.
Can someone guide me to a location or provide sample code for getting twitter data.
I used to do this in R but seems like python is better for this. If someone can provide a guide in either or both would be very much appreciated.(or some sample code with explanation)
Thanks

I recommend using sixohsix's twitter library for Python.
There is some documentation on the github page, and if you're familiar with at least a bit of Python (I didn't know Python very well when I started using it), then it's pretty easy to use. It supports API v1.1 (v1.0 is deprecated and doesn't even work anymore, afaik).
With some Python scripts on a Ubuntu netbook I was able to continuously query the API for almost a year now, without one crash. I wouldn't recommend R for this, especially if you're after a lot of data.
You can still use R for data analysis, you can actually plug it into your Python scripts directly using rpy2.

This package might be useful. It was just released a few days ago.
twitteR package for R

The Twitter API was updated from version 1.0 to version 1.1. Many codes are now defunct since authentication is needed. Many blog posts with code samples are no longer valid.
For Python, I prefer the bear's package.
For R, I think the standard package is twitteR.
Whatever you do, you'll have to authenticate your "application" as a developer: link.

Related

Using a SOAP WSDL with python

I have been trying to wrap my head around a few things and I havent found a concrete solution for the same.
I want to use a SOAP web service to get an XML data and then parse the received XML data.
So far, I have only found libraries compatible with python 2.xx and I want something comaptible with python 3.xx. I have tried Zeep but I wasnt able to configure it as its module was released on May 15th.
Anyway, I would like to be guided towards a library which can help me setup a SOAP client on python 3.6 allowing me to use its methods to send requests and consume the response.
My research has shown zeep is really the only currently maintained one. I'm using python 3.6 and using it for SOAP (5/2019).
Quick google search came up with these links which are fresh for 5/2019:
What SOAP libraries exist for Python 3.x? which I believe is already referenced in the comments (I'm new and can't comment).
Another link
https://www.slant.co/topics/268/~best-soap-client-libraries-for-python is good, though the "last updated" column is misleading. Zeep has been updated with in months, but the others have not been updated in years.

send http request using django and get results

This might seem like an extremely simple and stupid question yet i can't find a convenient answer.
I'm trying to use google's reverse geocodding api with django, as the website explains (at https://developers.google.com/maps/documentation/geocoding/start?csw=1#ReverseGeocoding) I'm supposed to send a request to the url :
https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=<_api_key>
But I can't find an appropriate way to send this request using django to google api.
To me it seems something so simple will be doable by some method built-in django but all I could find was modules to install.
If there's no way but installing other python modules which one's the best?
Well, the most straightforward way would be to install requests library and simply call:
result = requests.get(your_link)
You can find additional information (e.g., how to authenticate, use cookies, etc., as well as how to access data in response) in the library's docs. The requests library is very well written, very intuitive and simple to use. Quite a lot of smart people and companies use it, too, so it's not a half-baked library someone just hacked out over the weekend (as of this moment, it has 6060 commits and 595 contributors on GitHub).
If you absolutely must avoid external libraries, why not try urllib.request. It's a bit more complicated, and even the docs themselves recommend using requests if you prefer higher-level interface. But you definitely can get the job done with it. To get started, you can read the docs on how to use it to fetch data. Read this thread for an example of how to extract json from a response you'd get with urllib.

Python libraries for integrating Django with Facebook

I decide to write some applications using facebook and django (or even twisted, but it doesn't matter), and now I can't choose appropriate tools. I see there are many API-wrappers writed on Python exists for Facebook:
official, but seems no longer supported Python-SDK
new and actively developed, but seems too new Django-facebook
good old, but not maintained pyfacebook
simple, well-maintaned, but non-documented fandjango
some other very primitive tools
I saw some similar questions here, but I'm noticed that Facebook is periodically introduces big changes into their API and those advices may be already outdated, or may be new libraries appeared.
Also I'd like to know about most significant differences between those libraries. And of course good documentation and tutorials are welcome.
I think Django Facebook is a good choice for you. But my opinion is biased. I've written it for my startup Fashiolista.com and we run it in production. (Quite huge, so most edge cases have been resolved)
Django Facebook also include OpenFacebook, which is a python api client to the open graph protocol. It's the only python client I know which is fully up to date and actively maintained.
Have a look at:
https://github.com/tschellenbach/Django-facebook
PS.
Just released some new decorators which make it very simple to get started. These decorators are indeed very new and caused some bugs in the past days. The project itself is already a year old (since the open graph api was released) and otherwise quite stable.
http://www.mellowmorning.com/
The answer really depends on what it is you want to achieve as those APIs are pretty different.
pyfacebook - is for the older legacy API.
python-sdk - is for the "new" opengraph protocol (I wouldn't say its no longer supported as its just a thin wrapper over the facebook opengraph protocol, so supports all the new features that facebook provide instantly w/out needing dev work on the lib).
django-facebook - is a higher level than python-sdk and helps you to add facebook connection features to your site and also seems to pave the way to creating apps that live "inside" facebook rather than just helping sites that live outside facebook to get access to facebook data.
Never heard of fandjango and github seems to be down at the moment so can't comment on that.
If you just want to add user-login using facebook then something like django-socialauth might work out well for you.
If you want to start exploring the social graph then python-sdk is the way to go.
I'd also check to see if the functions you want are supported by the opengraph protocol, its improved over the last year but there is the odd thing it frustratingly doesn't support whereas the legacy api does support...
The best documentation is facebook itself, check out the graph-explorer - it's pretty fascinating...
It depends what you are trying to do. I had the same problem and ended up using django-social-auth , which lets you log in via Facebook and many other social networks.It also lets you extract the token from those networks and then use it.
For the facebook specific stuff, I use facebook-sdk, but since you have something managing the tokens, you could really replace it with any library if yours become outdated in upcoming years . It also means you can add more social networks later on.

Payment gateway with Python SDK compatible with GAE

I'm looking for a Payment gateway that offers Python SDK which would run on GAE. So far I've looked at Braintree[1] and TrustCommerce[2], and both required C-based libraries to work, which won't work on GAE. If there's no such thing, which payment gateway would you recommend that provides a possibly JSON-based API or a nice RESTful API.
[1] http://www.braintreepayments.com/
[2] http://www.trustcommerce.com/
Braintree uses PycURL library which is C-based
TrustCommerce comes with some C files that need to be compiled during install
EDIT:
I'll vote close on this, because it's been suggested that such thing is impossible because URLfetch has a 10 second limit which is not sufficient in this case. For those interested, it has been suggested to me that using a proxy for payment processing would be better.
It would be really helpful if you provided links. I googled and found this TrustCommerce, but I guess maybe it's a different company to the one you are talking about because they say there is sample Python code.
I didn't sign up for a trial account just to see if the Python API requires a C library. Afterall maybe it's not even the same TrustCommerce you have looked at.
This isn't really the right site to do your research, you should come back and ask for help if you have problems using the API when you have found/chosen one.

Bloomberg Server API and Ruby/Python

Im looking to write a new application in ruby/python which uses a feed from bloomberg and am stuck trying to find any documentation for using (or even setting up) Bloomberg Server API with either of these languages.
Does anyone have any good links to tutorials for this or maybe some boilerplate code to get set up? Or is it best to just stick to the three main supported languages?
The Bloomberg Open API (BLPAPI) v3.5 release now includes a native Python SDK.
http://www.openbloomberg.com/2012/11/21/open-api-blpapi-v3-5-x-released/
Did you check out some questions at SO on this. It might help you
Bloomberg API request timing out
Asynchronous data through Bloomberg's new data API (COM v3) with Python?
Resolver is an spreadsheet implementation in IronPython and has a very good integration for Bloomberg API
http://www.resolversystems.com/documentation/apidocs/MarketData_Bloomberg.html
Here is a simple Client access API which I wrote with the help of the mentioned links as well as some others. Not everything is implemented but it is a good start.
https://github.com/bpsmith/pybbg

Categories

Resources