想用python+selenium自動發表文章,卡在正文的代碼不知道怎么寫
想用html源代碼輸入,這樣直接就是帶格式的,但是標簽全時了,要么不能輸入,要么輸入的時候沒反應。
請教,要怎樣才能輸入呀


import requests
from bs4 import BeautifulSoup
from selenium.webdriver.support.ui import Select
from selenium import webdriver
import json
import time
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys
url=input('請輸入網址:')
res=requests.get(url)
soup=BeautifulSoup(res.text,'html.parser')
article_title=soup.find(id="activity-name")
account_name=soup.find(id="js_name")
account_ID=soup.find('span',class_="profile_meta_value")
article_content=soup.find(id="js_content")
try:
article_author = soup.find('span', class_="rich_media_meta rich_media_meta_text")
Article_Source=account_name.text.strip()+'(ID:'+account_ID.text+') 作者/'+article_author.text.strip()
except:
Article_Source=account_name.text.strip()+'(ID:'+account_ID.text+')'
try:
tag = article_content.contents[6].text
except:
tag=' '
f=open('content.txt','w',encoding='utf-8')
f.write(str(article_content))
f.close()
with open('cookie.json', 'r', encoding='utf-8') as f:
listCookies = json.loads(f.read())
driver = webdriver.Chrome()
driver.get("https://admin.jinrongbaguanv.com/#/welcome")
time.sleep(5)
for cookie in listCookies:
driver.add_cookie({
"domain":".xianzhipassport.91jinrong.com",
"name":cookie['name'],
"value":cookie['value'],
"path":'/',
"expires":None
})
driver.get("https://admin.jinrongbaguanv.com/#/welcome")
driver.get("https://admin.jinrongbaguanv.com/#/article/add")
time.sleep(3)
driver.find_element_by_id("title").send_keys(article_title.text.strip())
driver.find_element_by_id("originTitle").send_keys(article_title.text.strip())
driver.find_element_by_name("originUrl").send_keys(url)
driver.find_element_by_id("summary").send_keys(tag)
driver.find_element_by_id("author").send_keys(Article_Source)
article_class=Select(driver.find_element_by_id('belongToTopicId'))
article_class.select_by_value("100000")
driver.find_elements_by_name("author")[1].send_keys('tu')
driver.find_element_by_xpath('//div[@title="源代碼"]').click()
time.sleep(1.5)
driver.find_element_by_xpath('//div[@class="CodeMirror-lines"]').send_keys('111111111')
uj5u.com熱心網友回復:
太長的一般都得不到解決,好難得看。uj5u.com熱心網友回復:
看他的post資料直接post吧,要不你還得研究他這個編輯器uj5u.com熱心網友回復:
找到那個input設定value屬性轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/123862.html
上一篇:5GC中名詞解釋
