在python中使用selenium/chromedriver的Instagram后故事

在python中使用selenium/chromedriver的Instagram后故事,python,selenium,selenium-chromedriver,instagram,bots,Python,Selenium,Selenium Chromedriver,Instagram,Bots,我想创建一个机器人,它接收文件夹路径,并使用python和chromedriver将其所有img内容发布到instagram用户故事中(我已经有很多其他功能在使用此设置,所以我更愿意使用这些工具解决此问题)。如果有人创建或发现了类似于我描述的内容,请评论链接 我已经尝试使用chromedriver的移动仿真模式,并取得了一些成功。我能够进入文件选择屏幕,但当我返回instagram时,它不再进行移动仿真,并锁定了UI(它要求旋转设备)。我包括了当前为我正在使用的webdriver选择的选项。我还

我想创建一个机器人,它接收文件夹路径,并使用python和chromedriver将其所有img内容发布到instagram用户故事中(我已经有很多其他功能在使用此设置,所以我更愿意使用这些工具解决此问题)。如果有人创建或发现了类似于我描述的内容,请评论链接

我已经尝试使用chromedriver的移动仿真模式,并取得了一些成功。我能够进入文件选择屏幕,但当我返回instagram时,它不再进行移动仿真,并锁定了UI(它要求旋转设备)。我包括了当前为我正在使用的webdriver选择的选项。我还包括了用于将文件上载到故事的def

def\uuuu init\uuuuu(self、用户名、密码、actionstring、inspoaccounts、,
inspohashtags):
self.username=用户名
self.password=密码
self.actionString=str(actionString)
self.inspoAccounts=(str(inspoAccounts).split(“|”,30))
self.inspoHashtags=(str(inspoHashtags).split(“|”,30))
copions=Options()
copions.add_参数(“--incognito”)
copions.add_参数(“--start maximized”)
copions.add_参数('--user agent=“Mozilla/5.0(Windows Phone 10.0;Android 4.2.1;Microsoft;Lumia 640 XL LTE)AppleWebKit/537.36(KHTML,如Gecko)Chrome/42.0.2311.135 Mobile Safari/537.36 Edge/12.10166“)
self.driver=webdriver.Chrome(executable_path=“venv/Lib/chromedriver_win32/chromedriver.exe”,options=copions)
self.driver.delete_all_cookies()
def上传故事(self,path):
path=self.cleanPath(路径)
动作=动作链(self.driver)
element=self.driver.find_element_by_css_选择器(
“#react root>section>main>section>div.zGtbP>div>div>div>div:n子级(1)>按钮”)
#这是它要求我旋转设备的地方
动作。将元素移动到元素(元素)
操作。单击()
actions.perform()
时间。睡眠(随机。随机数(3,6))
自动输入。赢_激活(“打开”)
时间。睡眠(随机。随机数(4,6))
自动控制发送(“打开”,“编辑1”,路径)
时间。睡眠(随机。随机数(3,7))
autoit.control_send(“打开”、“编辑1”、“输入”)
时间。睡眠(随机。随机数(3,6))
self.driver.通过xpath(“/*[@id=\“react root\”]/section/footer/div/div/button”)查找元素。单击()

如果任何人有任何想法或任何项目,请随时发表评论。没有错误的答案

你可以用它上传故事。它完成基本的工作,没有标签、哈希标签等:

from instapy_cli import client
with client(user, passw) as cli:
    result = cli.upload(img_path, story=True)
其他可能性可能包括:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options 

driver.set_window_size(width, height)
,

,


我尝试了所有这些选择,但都没有成功。如果你有什么事要做,请告诉我!ChromeDevTools中的切换设备工具栏使它工作,但我无法用上面的方法复制它,也无法够到按钮。使用.send_键(ctrl、shift、m)可以达到该按钮,但由于某些原因,它不起作用。我只是用instapy_cli尝试了一下,效果很好,谢谢!没问题。你会选择这个作为接受的回答吗?这是我的第一次:D不再工作了,因为IG改变了api。selenium和.send_键(ctrl、shift、m)访问切换设备工具栏也存在同样的问题。有人知道如何解决这个问题,用Python和Selenium发布故事吗?
chrome_options = Options()
useragent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Mobile Safari/537.36"
chrome_options.add_argument(f"user-agent={useragent}")
chrome_options.add_experimental_option("mobileEmulation", {"deviceName":"Galaxy S5"}) #or whatever
driver = webdriver.Chrome(options=chrome_options)