getGifts.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:DouyuFan 作者: wangmengcn 项目源码 文件源码
def getGift(roomid):
    fp = webdriver.FirefoxProfile(
        r'/Users/eclipse/Library/Application Support/Firefox/Profiles/tmsbsjpg.default')
    browser = webdriver.Firefox(fp)
    browser.implicitly_wait(15)  # seconds
    browser.get("http://www.douyu.com/" + roomid)
    try:
        indexvideo = browser.find_element_by_class_name('cs-textarea')
        print type(indexvideo)
        indexvideo.send_keys('2333333333333')
        print indexvideo
        time.sleep(5)
        sendbut = browser.find_element_by_class_name('b-btn')
        ActionChains(browser).move_to_element(
            indexvideo).click(sendbut).perform()
        gift = browser.find_element_by_class_name('peck-cdn')
    except Exception, e:
        print str(e)
        browser.quit()

    times = 0
    while True:
        try:
            ActionChains(browser).move_to_element(gift).click(gift).perform()
            time.sleep(1)
            print times
            times += 1
        except Exception, e:
            print 'completed by an error'
            browser.quit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号