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()
评论列表
文章目录