使用seleniu在instagram中发送消息

2024-03-28 12:11:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我已成功登录Instagram。 我已直接打开并单击新邮件。 现在我想通过他们的昵称发送消息。 我看到子标签下有一个昵称,还有一个类似于单选检查的按钮。 但是,我无法单击以启用下一步并发送消息

enter image description here

enter image description here


Tags: 消息标签按钮instagram昵称新邮件
1条回答
网友
1楼 · 发布于 2024-03-28 12:11:43

选择一个或多个要向其发送消息的用户后,“下一步”按钮将启用。 手动执行(正如您所描述的,部分问题已经解决),您将看到,如果您检查元素,并使用例如右键单击复制XPATH,您可以使用Selenium的Next按钮

您没有提供代码示例,但在我的示例中,它如下所示:

element = driver.find_element_by_xpath("/html/body/div[4]/div/div[1]/div/div[2]/div/button")  # this is the XPATH of the Next button I copied
element.click()

# Your code here for the user selection

message_to_send="test"
element = driver.find_element_by_xpath("/html/body/div[1]/section/div/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/div[2]/textarea") # message box
element.send_keys(message_to_send)
element.send_keys(Keys.RETURN)  # you can also hit Enter or search the new Send button

如果您可以详细说明您的代码,回答起来会更容易,但这应该是可行的

相关问题 更多 >