//from bs4 import Beautiful Soup
import requests
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from urllib.request import urlopen
import time
try:
url='Subsidiary url'
r=requests.get(url)
soup=BeautifulSoup(r.text,"html.parser")
mr=soup.find(class_="ABA-article-contents" )
driver=webdriver.Chrome()
driver.get('http://cafe.naver.com/joonggonara')
login=driver.find_element_by_class_name('gnb_txt')
login.click()
id=driver.find_element_by_id('id')
id.send_keys ('Enter Account ID')
pw=driver.find_element_by_id('pw')
pw.send_keys ('PASSWORD ENTER')
login=driver.find_element_by_class_name('btn_global')
login.click()
menu=driver.find_element_by_xpath('//*[@id="menuLink0"]')
menu.click()
cafe_write= driver.find_element_by_xpath('//*[@id="cafe-info-data"]/div[3]/a/img')
cafe_write.click()
driver.switch_to_frame(driver.find_element_by_id("cafe_main"))
select=driver.find_element_by_xpath('//*[@id="boardCategory"]')
select.click()
select=driver.find_element_by_xpath('//*[@id="boardCategory"]/option[2]')
select.click()
subject=driver.find_element_by_xpath('//*[@id="subject"]')
subject.send_keys ('test')
write=driver.find_element_by_xpath('//*[@id="toolbox"]/tbody/tr[4]/td')
htmlck=driver.find_element_by_xpath('//*[@id="elHtmlMode"]')
htmlck.click()
ac=ActionChains(driver)
ac.move_to_element(write)
ac.click()
ac.send_keys(mr)
ac.perform()
except Exception as e:
print(e)
finally:
quit
To explain the code, it is a code created to parse the contents of the subsidiary using beautiful soup and put it in the variable mr so that the same text is written in another community designated.
The problem is that if you go to the writing page of the secondhand country that you set up and output mr in the writing area, it will appear as 0 on the console. If you output it as mr.text, it is normally output as non-html text.
I searched if the text method was a selnium-related function, but it wasn't... How can I print it out as html itself?
python selenium
© 2024 OneMinuteCode. All rights reserved.