댓글이나 방명록 도배 당했을 시 사용하시기 바랍니다.
from selenium import webdriver
from seleniuhttp://m.webdriver.common.keys import Keys
from seleniuhttp://m.webdriver.common.action_chains import ActionChains
import time
from random import *
from seleniuhttp://m.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import sys
from seleniuhttp://m.webdriver.common.by import By
from seleniuhttp://m.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
blog_str = "https://ndlessrain.tistory.com"
browser = webdriver.Chrome()
browser.maximize_window()
browser.get(blog_str+"/manage/comments")
max_page = 100 #전체 댓글 페이지 수
browser.get(blog_str+"/manage/ comments ")
curr_page = 1
while curr_page <= max_page:
#현재 페이지의 글 모두 선택
WebDriverWait(browser, timeout=3).until(lambda d: d.find_element(By.XPATH, r'//*[@id="checkComments"]'))
browser.find_element(By.XPATH, r'//*[@id="mArticle"]/div/div[1]/div[1]/label').click()
#변경 클릭
WebDriverWait(browser, timeout=3).until(lambda d: d.find_element(By.XPATH, r'//*[@id="mArticle"]/div/div[1]/div[2]/button'))
browser.find_element(By.XPATH, r'//*[@id="mArticle"]/div/div[1]/div[2]/button').click()
#비공개 클릭
WebDriverWait(browser, timeout=3).until(lambda d: d.find_element(By.XPATH, r'//*[@id="mArticle"]/div/div[1]/div[2]/div/ul/li[2]/label'))
browser.find_element(By.XPATH, r'//*[@id="mArticle"]/div/div[1]/div[2]/div/ul/li[2]/label').click()
#처리 완료될 때 까지 최대 1분 대기
WebDriverWait(browser, timeout=60).until_not(EC.visibility_of_element_located((By.XPATH, r'//*[@id="mArticle"]/div/div[1]/div[2]/button')))
if curr_page == max_page :
sys.exit("program done")
curr_page = curr_page + 1
#다음페이지 이동
page_str = blog_str+"/manage/ comments ?page="+str(curr_page)
browser.get(page_str)
time.sleep(1)
'Python' 카테고리의 다른 글
ui 파일 포함하여 pyinstaller (0) | 2024.11.01 |
---|---|
jupyter notebook 파일(ipynb)을 pyinstaller 방법 (0) | 2024.11.01 |
visual studio code "there is no formatter for 'python' files installed" (0) | 2024.08.19 |
RTX 4050 Laptop GPU tensorflow, CUDA 등 초기 설치 (0) | 2024.03.04 |
No module named 'transformers.models.transfo_xl.configuration_transfo_xl' (0) | 2024.01.23 |