![](/img/trans.png)
[英]How to copy all the text (using ctrl + c and ctrl + a comands) from a text file in python?
[英]How to get text with CTRL C
我想從textarea獲取文本,但是有問題。
圖片: https : //ibb.co/FDrWPhR
<textarea class="ac-ad-code-area " data-action-type="js" name="ad-code" readonly="readOnly" rows="4">
https://www.amazon.com/gp/product/B01MY0LW0Q/ref=as_li_tl?ie=UTF8&tag=tag-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B01MY0LW0Q&linkId={{link_id}}
</textarea>
因此,我選擇並復制了文本。
text_link = driver.find_element_by_xpath('//*[@id="ac-quicklink-ad-textlink"]/div[2]/span/textarea').send_keys(Keys.CONTROL, "c")
text_link為NoneType
如何使用“ CTRL + C”獲取此文本?
希望你理解這個問題。 對不起,英語技能差。
pyperclip
使用pyperclip
軟件包:
import pyperclip
pyperclip.paste()
有內置的方法可以使用
driver.find_element_by_xpath('//*[@id="ac-quicklink-ad-textlink"]/div[2]/span/textarea').getText();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.