小编mah*_*moh的帖子

使用Python请求登录Instagram

我试图在python中编写一个脚本,登录http://insta.friendorfollow.com/并获取没有关注的人员列表.我想使用"请求模块",到目前为止我做了很多尝试,没有运气.我的代码如下:

import requests, re

f = open('file', 'w')
r = requests.get('http://insta.friendorfollow.com/')
next_url = re.findall(ur'<a href=\"(.*)\" type=\"submit\"', r.content)

r = requests.get(next_url[0])

action = re.findall(ur'action=\"(.*)\"', r.content)
csrfmiddlewaretoken = re.findall(ur'name=\"csrfmiddlewaretoken\" value=\"(.*)\"', r.content)

print action
print csrfmiddlewaretoken

payload = {
'csrfmiddlewaretoken': csrfmiddlewaretoken[0],
'username': 'SOMEUSER',
'password':'SOMEPASS'
}

g = requests.post("https://instagram.com/"+action[0],
  data=payload, allow_redirects=True)


print >> f, g.text
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我我做错了什么吗?什么是正确的方式来做到这一点.一个脚本将非常感激.

python instagram

5
推荐指数
1
解决办法
5794
查看次数

标签 统计

instagram ×1

python ×1