本文来源吾爱破解论坛
在b站转发了500多条抽奖动态了,一次都没中。
500+条手动删太麻烦了,然后就写了个程序自动删除动态,分享一下。一起学习
[Python] 纯文本查看 复制代码
from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By import time class Bili(object): driver_path = r"D:\ProgramApp\chromedriver_win32\chromedriver.exe" def __init__(self): self.driver = webdriver.Chrome(executable_path=Bili.driver_path) self.login_url = "https://passport.bilibili.com/login" self.home_url = "https://www.bilibili.com/" self.space_url = "https://space.bilibili.com" def _login(self): self.driver.get(self.login_url) WebDriverWait(self.driver, timeout=1000).until(EC.url_to_be(self.home_url)) print("登陆成功") self._to_space() def _to_space(self): self.driver.get(self.space_url) space_url_id = self.driver.current_url dynamic_url = space_url_id + '/dynamic' for i in range(500): self.driver.get(dynamic_url) WebDriverWait(self.driver, timeout=30).until(EC.presence_of_all_elements_located((By.XPATH, "//*[@id='page-dynamic']/div[1]/div/div/div[1]/div[3]/p"))) self.driver.find_element_by_xpath("//*[@id='page-dynamic']/div[1]/div/div/div[1]/div[2]/div").click() time.sleep(1) del_btn = self.driver.find_element_by_xpath("//*[@id='page-dynamic']/div[1]/div/div/div[1]/div[3]/p") del_btn.click() time.sleep(2) ok_btn = self.driver.find_element_by_xpath("/html/body/div[3]/div/div[2]/div/div[2]/div[2]/button[1]") ok_btn.click() print("已删除%d条" % (i + 1)) def run(self): self._login() if __name__ == '__main__': bili = Bili() bili.run()本帖被以下淘专辑推荐: · 兄dei,上车吗?|主题: 376, 订阅: 863
版权声明:
本站所有资源均为站长或网友整理自互联网或站长购买自互联网,站长无法分辨资源版权出自何处,所以不承担任何版权以及其他问题带来的法律责任,如有侵权或者其他问题请联系站长删除!站长QQ754403226 谢谢。
- 上一篇: python变相破解校园网
- 下一篇: 【笔记】centos7.7配置多版本python虚拟环境