I am trying to get the data correlated with a user's feed tab on Instagram. Every time I google "get user feed" or anything similar, I am presented with how to get the recent photos that a user has posted.
However, I am trying to get the feed tab, or basically the trending posts of other people that I follow. I tried using Lev Pasha's Instagram API module, but the only related function that I could find was getPopularFeed(), which got posts from the explore page.
I know how to connect to the Instagram API and have done it using the code below, but have not managed to collect the feed tab.
from InstagramAPI import InstagramAPI
InstagramAPI = InstagramAPI("myusername", "mypassword")
InstagramAPI.login()
Update (6/2/2021):
I've decided to add a bit of info here regarding the Instagram API. I'd like to say that this answer is slightly "deprecated" in a sense, as the GitHub repo for this project has been taken down, and therefore it will become harder to develop updates and bug fixes for the module. As a result, I'd actually recommend that you don't use this module, as it will get you banned very quickly from the Instagram platform (the last update was in 2018, and therefore any User-Agent fixes and bot-detection workarounds will not be added).
I'd also like to say that as of now, there seem to be no good modules for the task of Instagram automation. As I've just said, the InstagramAPI module written in my post is long gone, and all the other API projects on Github are also archived / have no more moderation or updates.
TLDR: Maintaining an API which is being updated constantly by a huge corporation is not easy, and therefore you will get banned / blocked easily. I'd recommend using Lev Pasha's or ping's Instagram APIs, although they are both deprecated and might get you blocked quickly. The module in the answer below is also pretty good, although I've noticed that it hasn't been updated in almost 2 years. Also, it's built as a wrapper on top of ping's API.
You can use instapi module to solve your problem. Link to repo
Code example:
from instapi import bind, User
bind('myusername', 'mypassword')
user = User.from_username('some username')
for feed in user.iter_feeds():
# do something with feed
To install instapi using pip:
pip install git+https://github.com/uriyyo/instapi
Related
I'm pretty inexperienced with any form of http request more complicated than a basic GET query. I've tried to do research online, but I'm having trouble figuring out where to start because I don't know all the required terminology.
For several years I've worked a side job for a data entry company. Basically what I do is Google several things, find the results from a few specific webpages, and copy those URLs into the company's system. About two years ago I wrote a very basic Python program to do the Googling part for me, and now I want to rewrite it and expand it to do the rest of it as well.
The website uses a combination of POST and PATCH requests to update the information on the database, and because the information is attached to my account I assume there is some form of authentication involved. I don't have access to the system's backend so the best I can do is head to the Network tab under Inspect Element. I can't find anything in the requests' headers that seem to attach to my account.
What do I need to do to authenticate, and if it's not that simple, where's the best place to start learning?
Let me know if you need more information and I'll try to give you what you need--I don't know exactly what's required.
I am building a python script that is trying to stream a screen capture to my Facebook Page and to be able to retrieve all the comments from the Facebook Live stream real time so that I can do some processing in the middle of the stream.
The Facebook App was set up (in development mode) but when I tried to retrieve the comments from my live stream, I am only able to retrieve comments with their name and id ("from") that are made as the Facebook Page Admin, not comments that are made by other users. I need the user's id, user's name and their comments.
I understand that I need to get Facebook App to be live mode in order to retrieve all the comments with their details tagged to it. When I tried to get it, it tells me that I need to get the permission approved. I tried to fill in most of the stuff and try to get the two permission (manage_page for the comments and live video API for the streaming) but I was unable to because I left the platform empty.
Below is the message I got:
You do not have any platforms eligible for review. Please configure a platform on your Settings page.
The problem is when I tried to choose a platform that was shown in the list, python script does not fall in the list of platform.
Does anyone know of a solution or a different way to achieve what I need to retrieve?
Have you tried using PyLivestream?
It can be used to stream to Facebook Live using FFmpeg (to multiple services simultaneously actually, like Periscope, YouTube etc).
It adheres to the RTMPS requirement and should be an option for you if I interpret your needs correctly.
python -m pip install PyLivestream
Facebook Live
Facebook Live requires FFmpeg >= 4.2 due to mandatory RTMPS
configure your Facebook Live stream
Put stream ID from https://www.facebook.com/live/create into the file facebook.key
Run Python script for Facebook with chosen input
Check out the PyPi PyLivestream page for details.
To be able to retrieve all the comments from the Facebook Live stream
I'm not sure if this is possible using PyLivestream alone, but the Polls API can be used to represent VideoPoll objects in the Graph API, to create polls on live video broadcasts and get real-time responses from your viewers and can be created with the
POST /{live-video-id}/polls
endpoint on a LiveVideo object.
Upon creation, the API will return a VideoPoll object ID, which you can use to manipulate the poll and query for viewer interactions.
Guess you'll have to do a bit of digging to figure out the details,
but I believe this would be the right way to approach this task.
In order to get the "from" field when retrieving the comments, you need to have manage_pages permission from your Facebook App that is linked to your Facebook Page. You will need to submit an App review for your Facebook App that usually takes 1-3 days to process. If you are lucky, it will probably take about 6-8 hours.
Once it is approved, you can request the permission and get your application to go live.
Also use the Page Access token in your "access_token" field when invoking the API so that it will allow you to pull the "from" field, which contains the id and name of the user.
I have a problem that in theory should be easy, but I have been at this for days and just can't get it to work.
I have a Google account to which a few aliases are connected (The main gmail, a test thing I made a long time ago and a youtube channel). I render my videos on a cloud server and would like to then automatically upload them to this channel. I don't want to have to open the URL because this should work unattended. And by god, I can't figure it out. It's pretty baffling in how bad a state Google's official API docs are (or how dumb I am). I am using Python and Google's official client
So far, I've modified the python upload example from the python examples to incorporate service auth as described here. This alone took me way too long to figure out, I think Google's newer key format is bugged. If I run this as is, I get a "youtubeSignupRequired" error, because the main account doesn't have a youtube channel. After hours of research I found this link that pretty poorly describes the onBehalf parameters, but it seems these require a YouTube CMS account, which I don't have and I don't think I will get.
Am I missing something extremely obvious here? This seems like something that should not be hard to do at all.
I am making a web application that will monitor the amount of members and discussions in each one of the groups listed here (http://www.codecademy.com/groups#web) and display that information in nice graphs.
However, as you have already seen, it looks like I need to create an account and login with it.
Having in mind that my project is using Python for the server side, how do I do it? Which API is easier? (Google, FB or twitter?)
I would really love if you could also provide some examples because I am really new at this (and at Python too).
The official wrapper around the Twitter API for Python is this one. I used it and it's very easy. You should first read this page and also register an application to get OAuth keys.
Example:
import twitter
# Remember to put these values
api = twitter.Api(consumer_key="",
consumer_secret="",
access_token_key="",
access_token_secret="")
# Get your timeline
print api.GetHomeTimeline()
Hope it helps.
I've looked at a lot of questions and libs and didn't found exactly what I wanted. Here's the thing, I'm developing an application in python for a user to get all sorts of things from social networks accounts. I'm having trouble with facebook. I would like, if possible, a step-by-step tutorial on the code and libs to use to get a user's information, from posts to photos information (with the user's login information, and how to do it, because I've had a lot of problem with authentication).
Thank you
I strongly encourage you to use Facebook's own APIs.
First of all, check out documentation on Facebook's Graph API https://developers.facebook.com/docs/reference/api/. If you are not familiar with JSON, DO read a tutorial on it (for instance http://secretgeek.net/json_3mins.asp).
Once you grasp the concepts, start using this API. For Python, there are at several alternatives:
facebook/python-sdk https://github.com/facebook/python-sdk
pyFaceGraph https://github.com/iplatform/pyFaceGraph/
It is also semitrivial to write a simple HTTP client that uses the graph API
I would suggest you to check out the Python libraries, try out the examples in their documentation and see if they are working and do the stuff you need.
Only as a last resort, would I write a scraper and try to extract data with screenscraping (it is much more painful and breaks more easily).
I have not used this with Facebook, but in the past when I had to scrape a site that required login I used Mechanize to handle the login and scraping and Beautiful Soup to parse the resulting HTML.