python 清除 nexus 里面的镜像

python 清除 nexus 里面的镜像,第1张

在这里下对应的 chromedriver 

 https://chromedriver.storage.googleapis.com/ 

替换到此目录即可

 

chrome --remote-debugging-port=9222 --user-data-dir="D:/chrone_data"

import json
import os
import selenium
from selenium import webdriver
import pathlib
import time
from selenium.webdriver.common.keys import Keys

 
options = webdriver.ChromeOptions()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = webdriver.Chrome(options = options)
 
 
def SLEEP(min=3):
    time.sleep(min) 
import shutil
def publish(id):  
     
    start_url = "http://XXXX:"+ id
    # start_url = "http://XXXX"
    driver.get(start_url)  
    now_handle = driver.current_window_handle
    print(now_handle)
    # SLEEP(5)
    # driver.find_element_by_xpath('/html/body/div[1]/div/div/div[3]/div/div[2]/div/div/div/div/div[1]/div/div/div[1]/div/div/div/div/div/div[4]/div/div[2]/div[1]/div[2]/table[1]').click()
    SLEEP(3)
    driver.find_element_by_xpath('//*[@id="nx-button-1201"]').click()    
    SLEEP(1)
    driver.find_element_by_xpath('//*[@id="button-1006-btnInnerEl"]').click()
    SLEEP(3) 


if __name__ == '__main__': 
    # 获取下列表数据
    data = [
    {
        "id": "22b3686a9064fa3d24e25f3dc1f73a92",
        "repositoryName": "maven-releases",
        "group": "com.xxx",
        "name": "xxxx",
        "version": "0.0.3.29.tom.8",
        "format": "maven2"
    },
    {
        "id": "c60bc6b9612f47d35a7e604af359633f",
        "repositoryName": "maven-releases",
        "group": "com.xxx",
        "name": "xxxx",
        "version": "0.0.3.29.tom.9",
        "format": "maven2"
    } 
]
            
    for i in data:
        print("开始删除:" + i['name'] + "-" + i['version'])
        publish(i['id'])
        

第二个版本 v1.2

import json
import os
from requests import delete
import selenium
from selenium import webdriver
import pathlib
import time
from selenium.webdriver.common.keys import Keys

 
options = webdriver.ChromeOptions()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = webdriver.Chrome(options = options)
 
 
def SLEEP(min=3):
    time.sleep(min) 
import shutil
def publish():   
    now_handle = driver.current_window_handle
    print(now_handle)
    SLEEP(2)
    driver.find_element_by_xpath('/html/body/div[1]/div/div/div[3]/div/div[2]/div/div/div/div/div[1]/div/div/div[1]/div/div/div/div/div/div[4]/div/div[2]/div[1]/div[2]/table[1]').click()
    SLEEP(3)
    driver.find_element_by_xpath('/html/body/div[1]/div/div/div[3]/div/div[2]/div/div/div/div/div[2]/div/div/div[1]/div/div/div/div/div/div[1]/div/div[2]/div/div/a[2]').click()    
    SLEEP(1)
    driver.find_element_by_xpath('//*[@id="button-1006-btnInnerEl"]').click()
    SLEEP(3) 


if __name__ == '__main__': 
    start_url = "http://XXXX:XX"  # 起始链接 包含要删除的列表
    driver.get(start_url)
    while True:
        publish()

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/756726.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-30
下一篇 2022-04-30

发表评论

登录后才能评论

评论列表(0条)

保存