def ss(): import urllib3,test diction = {} diction2 = {} for i in range(1, 10): url = "http://www.sspw.pw/ssmm%s.php"; % (i) diction[url] = "" while 1: for url in diction: http = urllib3.PoolManager() r = http.request('get',url) data = str(r.data) if len(data) != 13: continue data = data[4:-1] if diction[url] != data: diction[url] = data host = "mgm" + url[-5] +"." + url[11:-10] key = diction[url] diction2[host] = key def select(host): i = "'%s'" %host import pymysql db = pymysql.connect("192.168.1.135", "root", "123123", "ss") cursor = db.cursor() sql = """SELECT * from s WHERE s_host=%s""" %(i) cursor.execute(sql) data = cursor.fetchone() print(data[1]) # if __name__ == '__main__':
#!/usr/bin/python3 import pymysql db = pymysql.connect("localhost", "root", "123123", "mysql") cursor = db.cursor() cursor.execute('''select Host,User from user;''') #cursor.execute('''select Host,User from user where User="root";''') data = cursor.fetchone() print(data) db.close()