Instagram API在本地运行,但不能在服务器上运行

时间:2020-10-30 15:09:03

标签: curl instagram instagram-api

我想用服务器调用instagram api。

我尝试在本地系统上执行以下操作:

curl https://api.coingecko.com/api/v3/coins/list   -->works perfectly
curl https://www.instagram.com/zitate.flx/?__a=1   -->works perfectly

在Linux服务器上:

curl https://api.coingecko.com/api/v3/coins/list   -->works perfectly
curl https://www.instagram.com/zitate.flx/?__a=1   -->doesn't work

我的问题:为什么对instagram API的请求在我的本地系统上有效但在服务器上不起作用?

1 个答案:

答案 0 :(得分:0)

import requests

def create_session():       
     cookie = {"name": "sessionid", "value":"{this is your session id}"}
     session = requests.Session()
     session.cookies.set(**cookie)
     return session

s = create_session()
response = s.get(https://www.instagram.com/zitate.flx/?__a=1)