def main(url): chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--start-maximized') browser = webdriver.Chrome(executable_path='./driver/chromedriver.exe', options=chrome_options) browser.get(url) slider = WebDriverWait(browser, 10).until( EC.element_to_be_clickable( (By.CSS_SELECTOR, "#gc-box > div > div.gt_slider > div.gt_slider_knob.gt_show"))) username = browser.find_element_by_id("login-username") username.send_keys('18956436295') password = browser.find_element_by_id("login-passwd") password.send_keys('abcd123456') soup = BeautifulSoup(browser.page_source, 'lxml') gt_cut_bg_slice = soup.find_all(class_='gt_cut_bg_slice') gt_cut_fullbg_slice = soup.find_all(class_='gt_cut_fullbg_slice') gap_image_url = re.findall(r'background-image:\surl\("(.*?)"\)', gt_cut_bg_slice[0].get('style'))[0].replace( 'webp', 'jpg') full_image_url = re.findall( r'background-image:\surl\("(.*?)"\)', gt_cut_fullbg_slice[0].get('style'))[0].replace('webp', 'jpg') gap_image = Image.open(BytesIO(requests.get(gap_image_url).content)) full_image = Image.open(BytesIO(requests.get(full_image_url).content)) gap_image_loc_list, full_image_loc_list = getRightPositions( gt_cut_bg_slice, gt_cut_fullbg_slice) gap_image = reorganImage(gap_image, gap_image_loc_list) full_image = reorganImage(full_image, full_image_loc_list) gap_image.save('1.jpg') full_image.save('2.jpg') distance = getGapOffset(gap_image, full_image) tracks = Tracks.getTracks(int(distance * 0.95), 12, 3) moveToGap(browser, slider, tracks) time.sleep(2)
def loadTracks(self, key, mode): "see sc below" self.scale = Tracks.Scale(key, mode) midifiles = ResourceList(self.MidiFilePath, ".mid") for m in midifiles: score = Tracks.Midi2Score(self.MidiFilePath + "/" + m) track = score.midiTrack2ScoreTrack(score.getTrack(0)) if m.startswith('Lead'): self.leadtrack = track elif m.startswith('Bass'): self.basstrack = track elif m.startswith('Chords'): self.chordstrack = track elif m.startswith('Drums'): self.drumstrack = track else: raise ValueError, "Can't match MIDI file %s to instrument" % m
def __init__(self, trackPaths, name=__name__): flask.Flask.__init__(self, name) self.registerRoutes() self.tracks={} for path in trackPaths: for track in Tracks.allTracks(path): self.tracks[track.name]=track self.player=Tracks.Player()
def main(url): browser = webdriver.Chrome() # 访问登录页面 browser.get(url) # 等待滑块出现 slider = WebDriverWait(browser, 10).until( EC.element_to_be_clickable( (By.CSS_SELECTOR, "#gc-box > div > div.gt_slider > div.gt_slider_knob.gt_show"))) # 随便填个账号密码 username = browser.find_element_by_id("login-username") username.send_keys('1234567') password = browser.find_element_by_id("login-passwd") password.send_keys('7654321') # 找验证码图片 soup = BeautifulSoup(browser.page_source, 'lxml') gt_cut_bg_slice = soup.find_all(class_='gt_cut_bg_slice') gt_cut_fullbg_slice = soup.find_all(class_='gt_cut_fullbg_slice') gap_image_url = re.findall(r'background-image:\surl\("(.*?)"\)', gt_cut_bg_slice[0].get('style'))[0].replace( 'webp', 'jpg') full_image_url = re.findall( r'background-image:\surl\("(.*?)"\)', gt_cut_fullbg_slice[0].get('style'))[0].replace('webp', 'jpg') print(gt_cut_bg_slice) print(gt_cut_fullbg_slice) print(gap_image_url) print(full_image_url) # --带残缺块的 gap_image = Image.open(BytesIO(requests.get(gap_image_url).content)) # --完整的 full_image = Image.open(BytesIO(requests.get(full_image_url).content)) # 获取图像块正确的位置 gap_image_loc_list, full_image_loc_list = getRightPositions( gt_cut_bg_slice, gt_cut_fullbg_slice) # 根据位置重新拼接 gap_image = reorganImage(gap_image, gap_image_loc_list) full_image = reorganImage(full_image, full_image_loc_list) gap_image.save('1.jpg') full_image.save('2.jpg') # 计算偏移量 distance = getGapOffset(gap_image, full_image) # 获取轨迹 tracks = Tracks.getTracks(int(distance * 0.95), 12, 3) print(tracks) # 模拟滑动 moveToGap(browser, slider, tracks) time.sleep(2)
def set_game(self): self.tracks = Tracks.Tracks(60, 30, 40, 600, 10, self.screen) self.tracks.set_busy(0) self.tracks.set_busy(1) self.tracks.set_busy(8) self.tracks.set_busy(9) self.fps = 30 self.speed = 150 self.hobos = [] self.add_hobos() self.trains = [] self.add_trains() self.init_screen = True self.is_started = True self.is_paused = True
def makePlayer(scene): "create and return a player" player = Tracks.beatDebugPlayer(scene.cs, scene.TimeQueue, scene.Params, scene.scale) player.setBPM(scene.tempo) lead = scene.orc.nameNumber['LeadSampler'] bass = scene.orc.nameNumber['BassSampler'] chords = scene.orc.nameNumber['ChordsSampler'] drums = scene.orc.nameNumber['DrumsSampler'] player.beatInstrumentMap(1, Lead=[scene.leadtrack, lead], Bass=[scene.basstrack, bass], Chords=[scene.chordstrack, chords], Drums=[scene.drumstrack, drums]) return player
def test_module(): Features.test_module() print print Tracks.test_module() print