instagram可读yaml rpc api,便于instagram调度和升级
instabotnet的Python项目详细描述
Instagram僵尸网络
编写可读的声明性yaml文件以控制僵尸网络
待办事项
为每个操作发出事件在登录时通知中为新关注者、新评论、评论引用、用户标记引用发出事件使用pytest重写测试对ci使用无人机- 在登录时发出事件,添加followers number、posts number、following、timestamp等信息(以便以后可以使用由开始和结束会话组成的时间窗口进行分析)
- 在任务结束时发出事件
修复筛选器,如果给定的数据不足,筛选器应请求模型数据- 在登录时实现线程读取
- 实现线程读取消息,将每个消息作为事件发出
Direct_v2_收件箱()->;
Response:viewer:Userinbox:threads:[thread_id:Strthread_v2_id:Strpending:Boolread_state:ReadStateusers:[User]items:[item_id:Intitem_type:"media_share"|"text"|"link"timestamp:Intuser_id:Intdevice_timestamp?:Intmedia_share?:Mediatext?:Strlink?:link_url:Str]thread_type:privatehas_newer:Boolhas_older:Boollast_seen_at:Anynewest_cursor:Stroldest_cursor:Stris_spam:Boollast_activity_at:Timestamplast_seen_at:[user_id]:timestamp:Timestampitem_id:Int]next_cursor:cursor_thread_v2_id:Intcursor_timestamp_seconds:Intunseen_count:Intunseen_count_ts:Intpending_requests_total:intstatus:"ok"| StrReadState:0 | 1
直接线程(线程ID)不是线程ID->;
Response:thread:Thread
要获取最后未看到的消息: 1个呼叫线程2收件箱() 2如果res['inbox']['unseen_count']>;0 2获取线程id,其中
->addParam('persistentBadging', 'true') ->addParam('use_unified_inbox', 'true'); /** * Marks an item from given thread as seen. * * @param string $threadId Thread ID. * @param string $threadItemId Thread item ID. * * @throws \InstagramAPI\Exception\InstagramException * * @return \InstagramAPI\Response\DirectSeenItemResponse */ public function markItemSeen( $threadId, $threadItemId) { return $this->ig->request("direct_v2/threads/{$threadId}/items/{$threadItemId}/seen/") ->addPost('use_unified_inbox', 'true') ->addPost('action', 'mark_seen') ->addPost('thread_id', $threadId) ->addPost('item_id', $threadItemId) ->addPost('_uuid', $this->ig->uuid) ->addPost('_csrftoken', $this->ig->client->getToken()) ->setSignedPost(false) ->getResponse(new Response\DirectSeenItemResponse()); }
外壳使用
主模块处理yaml脚本,如下所示:
name:test_commentbot:username:usernamepassword:passwordactions:-name:comment on 10 posts from @kimkardashiannodes:-kimkardashianedges:-user_feed:amount:10-comment:max:1comments:-["hello{author}!!!"]-["comestai?","comeva?"]-["urlworkstoo!http://instagram.com"]
要执行上述操作,请运行:
python3 -m instabotnet test_comment.yaml
python api用法
在python模块内部使用:
frominstabotnetimportexecuteexecute('test_comment.yaml',{'username':'user','some_variables':'bo'})
环境变量可在env对象下访问
传递给execute的变量可以进行变异,execute函数返回一个包含从scrape
操作收集的数据的对象。
变量被修改以支持多脚本特性,其中许多模板在一个文件中被一个接一个地链接起来,并且可以将数据传递到下一个对变量进行修改的模板。
对settings变量进行变异以更新cookies和下一个bot迭代的其他数据也很有用。
{{}中的所有代码都是通过eval调用计算的,这意味着模板可以充满条件和复杂的行为,例如通过http调用获取上传照片的标题,或者从数组变量中获取随机项。 内部评估代码可用
- 变量
- 随机模块
- 所有函数
- 数据对象中的变量
- 用于进行api调用的urlopen模块
- JSON模块 {{{}}中的代码的一个限制是它只能由一个语句组成,并且只能返回列表或字符串。
模板中的每个操作都会发出一个事件,所有这些事件都可以在execute返回的对象中使用:
"template_name":"test_follow","action_name":"test_follow_famous_people","type":"follow","node":"kimkarkdashian","args":{},"metadata":{"username":"","proxy":""}
其他事件也会发出,例如有人跟踪您时:
"type": "got_followed",
"node": "username"