簡體   English   中英

使用 Selenium Python 將文件上傳到 Twitter

[英]Upload file to Twitter with Selenium Python

我正在嘗試制作一個 twitter 機器人,我正在使用 Selenium 和 Python。

我已經嘗試過這個頁面的方法: 在 Python 中使用 Selenium 上傳文件

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')

我無法上傳圖片此代碼無效 在此處輸入圖片說明

我認為 Selenium 只適用於網頁。 您可以嘗試使用請求,但在沒有 Twitter API 的情況下很難抓取/使用 Twitter。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM