Home > other >  Send text, want to use selenuim achieve automatic input
Send text, want to use selenuim achieve automatic input

Time:10-10

Want to use python + selenium automatically published an article, don't know how to write CARDS in the body of the code

Want to use the HTML source code input, this is with format directly, but the label full-time, or don't have input, or the input have no reaction,

Ask, how can enter





 import requests 
The from bs4 import BeautifulSoup
The from the selenium. Webdriver. Support. The UI import the Select
The from the selenium import webdriver
The import json
The import time
The from selenium.webdriver.com mon. Action_chains import ActionChains
The from the selenium. Webdriver. Support. Select the import the select
The from selenium.webdriver.com mon. Keys import keys

Url=input (" please enter the url:)
Res=requests. Get (url)
Soup=BeautifulSoup (res) text, '. The HTML parser)

Article_title=soup. The find (id="activity - the name")
Account_name=soup. The find (id="js_name")
Account_ID=soup. The find (' span, class_="profile_meta_value")
Article_content=soup. The find (id="js_content")
Try:
Article_author=soup. The find (' span, class_="rich_media_meta rich_media_meta_text")
Article_Source=account_name. Text. Strip () + "(ID: '+ account_ID. Text +) the authors/' + article_author. Text. The strip ()
Except:
Article_Source=account_name. Text. Strip () + "(ID: '+ account_ID. Text +') '
Try:
Tag=article_content. Contents [6]. The text
Except:
Tag='

F=open (' content. TXT ', 'w', encoding="utf-8")
F.w rite (STR (article_content))
F. lose ()

With the open (' cookie. Json ', 'r', encoding="utf-8") as f:
ListCookies=json. Loads (f.r ead ())

Driver=webdriver. Chrome ()
Driver. The get (" https://admin.jinrongbaguanv.com/#/welcome ")
Time. Sleep (5)

For cookie in listCookies:
Driver. Add_cookie ({
"Domain" : "xianzhipassport.91jinrong.com",
"Name" : cookies (' name '),
"Value" : cookies [' value '],
"Path" : '/',
"Expires" : None
})

Driver. The get (" https://admin.jinrongbaguanv.com/#/welcome ")
Driver. The 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="source code"] "). Click ()
Time. Sleep (1.5)
Driver. Find_element_by_xpath ('//div [@] '). The send_keys (' 111111111 ')

CodePudding user response:

Too long is not solved, generally good rare to see,

CodePudding user response:

Look at his post data directly post, or you have to study his this editor

CodePudding user response:

Find the input value attribute set