Open dentarg opened 8 years ago
Instagram has severley limited what API clients can do, needing explicit permission from users, even to get public content, if I understand things correctly (https://www.instagram.com/developer/authorization/, https://www.instagram.com/developer/review/).
Possible solution though, https://www.instagram.com/<user>/media
returns nice JSON (e.g. https://www.instagram.com/instagram/media). In that JSON, we could look for the caption
belonging to the photo. We have the code
from the URL posted (https://www.instagram.com/p/<code>/
, but we also need to get the username. We could extract the username from <meta content="See this Instagram video by @elonmusk • 62.4k likes" name="description" />
on the photo page.
https://www.instagram.com/
/media returns nice JSON
No more, now 404
Also, Instagram (tested https://www.instagram.com/p/BAqirNbwEc0/) now triggers exception:
argh <TitleReaderPlugin []> (<type 'exceptions.TypeError'>, TypeError("object of type 'NoneType' has no len()",), <traceback object at 0x7fb54672f3f8>) [('/home/rufwebot/pynik/ircbot.py', 64, 'execute_plugins', 'plugin.__class__.__dict__[trigger](plugin, self, *arguments)'), ('/home/rufwebot/pynik/plugins/title_reader.py', 89, 'on_privmsg', 'bot.tell(target, self.clean(url, title))'), ('/home/rufwebot/pynik/ircbot.py', 112, 'tell', 'return self.client.tell(target, message)'), ('/home/rufwebot/pynik/ircclient/ircclient.py', 91, 'tell', 'if len(string) >= 399:')]
This is of no help:
This would be great: