贴吧帮顶脚本
Posted GarVicker
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了贴吧帮顶脚本相关的知识,希望对你有一定的参考价值。
这是一个进入贴吧点开帖子后输入信息。这时会弹出要求登录的frame,填写后登录即可帮顶成功
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
driver=webdriver.Firefox()
driver.get("https://www.baidu.com/")
driver.find_element_by_xpath(‘/html/body/div[1]/div[1]/div/div[3]/a[5]‘).click()
driver.find_element_by_id("wd1").clear()
driver.find_element_by_id("wd1").send_keys(u"虎扑")
driver.find_element_by_link_text(u"进入贴吧").click()#在搜索框输入贴吧名字后进入贴吧
time.sleep(10)
driver.find_element_by_partial_link_text(u"虎扑吧鉴定").click()
#driver.find_element_by_partial_link_text(u"各位大神帮我看看这些是").click()
time.sleep(10)
all_handles=driver.window_handles#这时会出现新的窗口,获得这个窗口的handle进去帖子
driver.switch_to.window(all_handles[1])
driver.find_element_by_id("quick_reply").click()
time.sleep(5)
#driver.switch_to.window(all_handles[2])#进入登录
driver.find_element_by_id("TANGRAM__PSP_23__userName").clear()
driver.find_element_by_id("TANGRAM__PSP_23__userName").send_keys("百度用户名")
driver.find_element_by_id("TANGRAM__PSP_23__password").clear()
driver.find_element_by_id("TANGRAM__PSP_23__password").send_keys("百度密码")
driver.find_element_by_id("TANGRAM__PSP_23__submit").click()
time.sleep(15)
#driver.switch_to.window(all_handles[0])#登录小窗口不需要switch,还是在原窗口
driver.find_element_by_id("quick_reply").click()
driver.find_element_by_id("ueditor_replace").send_keys(u‘bd‘)#在内容的框内写入内容
driver.find_element_by_xpath(‘/html/body/div[6]/div/div/div[2]/div/div[5]/div[3]/div/div[3]/div[3]/div/a/span/em‘).click()
print ‘finish‘
以上是关于贴吧帮顶脚本的主要内容,如果未能解决你的问题,请参考以下文章