python登录zblog更新未完成

python登录zblog更新未完成

# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import time
import os
from pyquery import PyQuery as pq
import random


def zblogphp(title,content):
        pass
        chrome_options = webdriver.ChromeOptions()
        #chrome_options.add_argument("headless") # 不打开浏览器

        driver_path = "./bin/chromedriver.exe"
        driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_path)

        url='http://www.网址.com/zb_system/login.php'
        driver.get(url)
        driver.find_element_by_id("edtUserName").send_keys('用户名')
        driver.find_element_by_id("edtPassWord").send_keys(u"密码")
        driver.find_element_by_id("btnPost").click()
        time.sleep(5)
        url='http://www.网址.com/zb_system/cmd.php?act=ArticleEdt'
        driver.get(url)
        time.sleep(5)
        driver.find_element_by_id("edtTitle").send_keys(title)
        driver.switch_to.frame(driver.find_element_by_id('ueditor_1'))# 切入
        driver.find_element_by_xpath("/html/body").send_keys(content)
        driver.switch_to_default_content()   # 切出
        driver.find_element_by_id("btnPost").click()
        time.sleep(5)
        driver.quit()

猜你喜欢

转载自blog.csdn.net/woaisjm/article/details/112821338