Gitee 를 사용 하여 python 스 크 립 트 를 자동화 배치 하 는 상세 한 과정

전기 준비
1.1 설치 환경
1.python 3 설치
2、명령 줄 을 열 고 selenium 설치

pip install selenium
2.python 코드
2.1 소스 코드

#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
from selenium import webdriver
from selenium.webdriver.common.alert import Alert

#         gitee    
driver = webdriver.Chrome()
driver.get('https://gitee.com/login')
#       
driver.maximize_window()
time.sleep(2)

#     --  html id        --      
user_login = driver.find_element_by_id('user_login')
user_login.send_keys("        ")
#     --  html id        --      
driver.find_element_by_id('user_password').send_keys("        ")
#       --  xpath      
driver.find_element_by_xpath(
    '/html/body/div[2]/div[2]/div[1]/div/div[2]/div/form[1]/div[2]/div/div/div[4]/input').click()

time.sleep(2)

#    gitee pages  --  you_gitee_id
driver.get('https://gitee.com/    you_gitee_id/    you_gitee_id/pages')
#       --  xpath      
driver.find_element_by_xpath('/html/body/div[3]/div[2]/div/div[2]/div[1]/form/div[7]').click()
#        --             
Alert(driver).accept()

#   5   
time.sleep(5)

#   print       ,               ,   try     
print("  ")

#       ,     
driver.quit()

#       
#       D ,           
fp = open("D:\log.txt", "a+")
now_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
fp.write("auto update time:{0}
".format(now_time)) fp.close()
2.2 주의사항
xpath 는 chrom 홈 페이지 에서 F12 를 누 르 면 볼 수 있 습 니 다.
시연 과정

chromeDrive 실행 가능 한 드라이버 를 python 루트 디 렉 터 리 에 버 려 야 합 니 다(python.exe 와 함께 놓 으 십시오)
다운로드 주소
http://chromedriver.storage.googleapis.com/index.html

이상 은 Gitee 를 사용 하여 python 스 크 립 트 를 자동화 배치 하 는 상세 한 과정 입 니 다.Gitee 자동 배치 python 에 관 한 자 료 는 다른 관련 글 을 주목 하 십시오!

좋은 웹페이지 즐겨찾기