使用 Selenium 将文件上传到 Twitter Python

Upload file to Twitter with Selenium Python

我正在尝试制作一个 Twitter 机器人,我正在使用 Seleniumwith Python。

我试过这个页面的方法:

HTML:

<input accept="image/jpeg,image/png,image/webp,image/gif,video/mp4,video/quicktime,video/webm" multiple="" tabindex="-1" type="file" data-focusable="true" class="r-8akbif r-orgf3d r-1udh08x r-u8s1d r-xjis5s r-1wyyakw" data-testid="fileInput">

代码:

button = driver.find_element_by_xpath('//*[@id='react-root']/div/div/div[2]/main/div/div/div/div/div/div[2]/div/div[2]/div[1]/div/div/div/div[2]/div[2]/div/div/div[1]/input')
button.click()
button.send_keys('C://Users/Yagmur/Desktop/TwitterBot/2020-09-21data.png')

我无法上传图片此代码无效enter image description here

我认为 Selenium 只适用于网页。您可以尝试使用请求,但如果没有 Twitter API..

,很难 scrape/work 使用 Twitter