【发布时间】:2018-09-05 01:38:44
【问题描述】:
我正在创建一个对用户照片发表评论的 Instagram 机器人。我知道已经有像InstaPy 这样的解决方案,但它对我不起作用,我已经完成了 99% 的自己的 js 解决方案。
有没有办法让我以编程方式发帖?我已经设置了 textArea.value 并尝试提交包装表单(它只是刷新页面)。我还尝试“单击”提交按钮,但它没有导致它执行任何操作。我还尝试在 textarea 中“输入”,但如果没有屏幕上的任何实际用户交互以及尝试提交实际请求,这似乎是不可能的(似乎我的标题不匹配,我得到了403错误。)下面是我目前正在做的代码sn-p。
var commentTextArea = document.getElementsByClassName('Ypffh')[0];
if (commentTextArea) {
// Text area for posting comment
commentTextArea.textContent = "This is my comment :)";
setTimeout(function() {
// Comment submit button
var submitButton = document.getElementsByClassName('LCjcc')[0];
submitButton.disabled = false;
submitButton.click(); // doesn't fire anything. I can see in chrome dev tools there is no event event attached to this even when enabled which is odd
// Comment form
// Submitting form expectedly refreshes page
// Tried add my own submit listener with return false && e.preventDefault and neither worked
var form = document.querySelector('X7cDz');
if (form) {
form.submit();
}
}, 2000);
}
【问题讨论】:
-
代码示例....
-
@DenisTsoi 完成 :)
-
Instagram 可能检测到您正在使用机器人。
-
你解决了吗?
标签: javascript instagram