Skip to content

Instantly share code, notes, and snippets.

@jackhuntcn
Last active June 9, 2018 17:00
Show Gist options
  • Save jackhuntcn/e588ef2022f46f889aa5a6313a3fdec0 to your computer and use it in GitHub Desktop.
Save jackhuntcn/e588ef2022f46f889aa5a6313a3fdec0 to your computer and use it in GitHub Desktop.
#coding:utf-8
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
import re
driver = webdriver.Chrome()
driver.set_window_size(1024, 768)
driver.set_page_load_timeout(60)
wait = WebDriverWait(driver, 10)
url = "http://h5.gaoshouyou.com/h5_game/jolin/index.html"
driver.get(url)
k = 0
while k < 100:
try:
box = wait.until(EC.presence_of_element_located((By.ID, 'box')))
spans = box.find_elements_by_tag_name('span')
for i, span in enumerate(spans):
style = span.get_attribute('style')
if re.search(r'2\.png', style):
span.click()
except:
pass
time.sleep(0.2)
k += 1
time.sleep(120)
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment