def get_urlid(self, word, n,): id_list = [] img_list = [] price_list =[] title_list = [] print('========== KEYWORD IS:%s ==========' % word) url = self.front+word+self.behind+n try: page = dynamic.dynamic(url) except: print('*---------- CONNECT FAILED ----------*') try: page = dynamic.dynamic(url) print('********** RECONNECT SUCCES **********') except: print('*----------CONNECT FAILED----------*') page = dynamic.dynamic(url) print('********** RECONNECT SUCCES **********') soup = BeautifulSoup(page.text,'lxml') item = soup.find_all('div',{'class':'item'}) for i in item: ### 获取产品id info_more = i.find('div',{'class':'info-more'}) try: urlid = info_more.find('input',{'class':'atc-product-id'})['value'] except: urlid = '#######' ### 获取产品图片地址 try: img = i.find('img', {'class': 'picCore'}) if img.get('src'): img_src = img['src'][2:] elif img.get('image-src'): img_src = img['image-src'][2:] else: img_src = '####' except: img_src = '####' ### 获取产品标题 try: title = i.find('a',{'class':'history-item product '})['title'] title = re.sub(r"'",' ',title) title = re.sub(r'"',' ',title) except: title = '####' ### 获取产品价格 try: price_span = i.find_all('span',{'class':'price price-m'}) for i in price_span: price = i.find('span',{'class':'value'}).get_text() except: price = '####' price_list.append(price) img_list.append(img_src) id_list.append(urlid) title_list.append(title) return id_list,img_list,price_list,title_list
def solve_it(input_data): item_count, capacity, items = parse_input(input_data) from greedy import greedy_most_valuable, greedy_least_weight, greedy_most_dense from dynamic import dynamic if item_count == 30: #value, taken = greedy_most_valuable(item_count, capacity, items) #value, taken = greedy_least_weight(item_count, capacity, items) value, taken = dynamic(item_count, capacity, items) elif item_count == 50: value, taken = dynamic(item_count, capacity, items) elif item_count == 200: value, taken = dynamic(item_count, capacity, items) else: from branch import breadth_first value, taken = breadth_first(item_count, capacity, items) return prepare_output(value, taken)
def run(): path = input( "Which method do you want to use? \nBrute force (1), Dynamic (2), Best First Branch Bound (3), or Backtracking (4)?\nOr press q to quit : " ) if path == '1': time1 = datetime.datetime.now() print(bruteforce.bruteforce(W, items[2], items[1], len(items[0]))) time2 = datetime.datetime.now() tdelta = time2 - time1 print("Brute force: Time taken: %s ms" % int(tdelta.total_seconds() * 1000)) print("\n") run() elif path == '2': time1 = datetime.datetime.now() print(dynamic.dynamic(W, items[2], items[1], len(items[0]))) time2 = datetime.datetime.now() tdelta = time2 - time1 print("Dynamic: Time taken: %s ms" % int(tdelta.total_seconds() * 1000)) print("\n") run() elif path == '3': time1 = datetime.datetime.now() print( firstBranchBound.firstBranchBound(W, items[2], items[1], len(items[0]))) time2 = datetime.datetime.now() tdelta = time2 - time1 print("Best First Branch Bound: Time taken: %s ms" % int(tdelta.total_seconds() * 1000)) print("\n") run() elif path == '4': time1 = datetime.datetime.now() print(backtracking.backtracking(W, items[2], items[1], len(items[0]))) time2 = datetime.datetime.now() tdelta = time2 - time1 print("Backtracking: Time taken: %s ms" % int(tdelta.total_seconds() * 1000)) print("\n") run() elif path == 'q': sys.exit("See ya!") else: print("Error: no valid option chosen. Please try again.") print("\n") run()
def run(): path = input("Which method do you want to use? \nBrute force (1), Dynamic (2), Best First Branch Bound (3), or Backtracking (4)?\nOr press q to quit : ") if path == '1': time1 = datetime.datetime.now() print( bruteforce.bruteforce(W, items[2], items[1], len(items[0])) ) time2 = datetime.datetime.now() tdelta = time2 - time1 print("Brute force: Time taken: %s ms" % int(tdelta.total_seconds()*1000) ) print("\n") run() elif path == '2': time1 = datetime.datetime.now() print( dynamic.dynamic(W, items[2], items[1], len(items[0])) ) time2 = datetime.datetime.now() tdelta = time2 - time1 print("Dynamic: Time taken: %s ms" % int(tdelta.total_seconds()*1000) ) print("\n") run() elif path == '3': time1 = datetime.datetime.now() print( firstBranchBound.firstBranchBound(W, items[2], items[1], len(items[0])) ) time2 = datetime.datetime.now() tdelta = time2 - time1 print("Best First Branch Bound: Time taken: %s ms" % int(tdelta.total_seconds()*1000) ) print("\n") run() elif path == '4': time1 = datetime.datetime.now() print( backtracking.backtracking(W, items[2], items[1], len(items[0])) ) time2 = datetime.datetime.now() tdelta = time2 - time1 print("Backtracking: Time taken: %s ms" % int(tdelta.total_seconds()*1000) ) print("\n") run() elif path == 'q': sys.exit("See ya!") else: print("Error: no valid option chosen. Please try again.") print("\n") run()
peframe.autoanalysis(filename) elif (input=='exit'): return if __name__ == '__main__': if not os.geteuid() == 0: sys.exit("\nOnly root can run this script\n") completer = main(["sandbox","static","exit()"]) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') filename = raw_input('Path to malware file: ') if not os.path.isfile(filename): sys.exit("\nFile not found\n") if not filename.endswith('.exe'): sys.exit("\n Only executable file are accepted") while(1): try: input = raw_input('Hunter>> ') if (input=="static"): print "Start the static analysis" static(filename) elif (input=="sandbox"): print "Dynamic analysis for suspicious files" dynamic.dynamic(filename) elif (input=='exit()'): sys.exit(0) else : print "This command is not used" except KeyboardInterrupt: print "type exit() to stop" except EOFError: print "type exit() to stop"
import dynamic import numpy as np import copy if __name__ == '__main__': epoch = 10000 # Trainning time _pred_time = 50 # The length of each episode _n = 5 # The number of running each policy agent = ilqr.iLQG(umax=10000, state_dim=10, action_dim=5, pred_time=_pred_time, n=_n) env = dynamic.dynamic(dof=5, delta_t=0.02) for epo in range(epoch): for n in range(_n): x_sequence = [] u_sequence = [] env.init_sys() # Initialize the system assert env.pos[0] == 0 for pred in range(_pred_time): x_cur = np.hstack((env.pos, env.vel)) x_sequence.append(x_cur) torque = agent.policy(x_cur, pred) u_sequence.append(torque)
#!/usr/bin/env python import sys import static import dynamic import memory if __name__ == "__main__": if len(sys.argv) == 1: print "Enter your file name as argument" sys.exit() print "Performing static analysis" static.static(sys.argv[1]) dynamic.dynamic(sys.argv[1], sys.argv[2]) memory.memory(sys.argv[3])
import frame import dynamic import image if __name__ == '__main__': # frame.get_frame_from_video() dynamic.dynamic() image.image()
weights, values = make_Weights_and_values(multiplier * n, max_weight, max_value) b_025 = int(0.25 * sum(weights)) b_05 = 2 * b_025 b_075 = b_05 + b_025 tab_w_v = make_tab(weights, values) X.append(multiplier * n) ########################### 2 ############################################# #Zbadać zależność czasu obliczeń t od liczby paczek n (minimum #10 punktów pomiarowych dostosowanych do wymagań czasowych BF) dla #metody PD, BF1, BF2 i GH4 dla b = 50%Σs(ai). start = time.time() profit_max_05 = dynamic(multiplier * n, b_05, weights, values) end = time.time() dynnamic_time_b05.append(end - start) if n <= 10: start = time.time() full(b_05, weights, values) end = time.time() full_time_b05.append(end - start) else: full_time_b05.append(0) start = time.time() back(tab_w_v, b_05) end = time.time() backtracking_time_b05.append(end - start)
return if __name__ == '__main__': if not os.geteuid() == 0: sys.exit("\nOnly root can run this script\n") completer = main(["sandbox", "static", "exit()"]) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') filename = raw_input('Path to malware file: ') if not os.path.isfile(filename): sys.exit("\nFile not found\n") if not filename.endswith('.exe'): sys.exit("\n Only executable file are accepted") while (1): try: input = raw_input('Hunter>> ') if (input == "static"): print "Start the static analysis" static(filename) elif (input == "sandbox"): print "Dynamic analysis for suspicious files" dynamic.dynamic(filename) elif (input == 'exit()'): sys.exit(0) else: print "This command is not used" except KeyboardInterrupt: print "type exit() to stop" except EOFError: print "type exit() to stop"