使用 Python 和 Selenium 发送 Instagram 评论

1 html python selenium instagram

我想使用 Python 和 Selenium 提交评论。Instagram 网页中的评论框如下所示:

\n\n
<textarea aria-label="A\xc3\xb1ade un comentario..." placeholder="A\xc3\xb1ade un comentario..." class="Ypffh" autocomplete="off" autocorrect="off" style="height: 18px;"></textarea>\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的Python代码:

\n\n
coment_box = driver.find_elements_by_css_selector("form textarea") \ncoment_box.send_keys("Nice picture")\n
Run Code Online (Sandbox Code Playgroud)\n\n

我尝试使用,find_by_xpath("here_xpath")但它返回一个错误,指出: AttributeError: \'list\' 对象没有属性 \'send_keys\'。

\n

小智 6

我点击了两次。有效。我的意思是你必须输入以下代码:(写两次点击行)

commentArea = driver.find_element_by_class_name('Ypffh')
commentArea.click()
sleep(5)
commentArea = driver.find_element_by_class_name('Ypffh')
commentArea.click()
commentArea.send_keys("YOUR COMMENT HERE...")
Run Code Online (Sandbox Code Playgroud)