def fetch_test1(match_number): crawl_url_1 = 'http://211.151.108.43/soccer/match/' crawl_url_2 = '/ah/handicap/27/' webpage = crawl_url_1 + str(match_number) + crawl_url_2 entry = data_class_test.odds_trend() entry = crawl_engine.capture_matchesdata(webpage) database_conn.db_conn(entry)
def fetch_byterm(seed): crawl_url_1 = 'http://211.151.108.43/soccer/match/' crawl_url_2 = '/ah/handicap/27/' mlist = crawl_engine.get_zucai(seed) for i in mlist: webpage = crawl_url_1 + i + crawl_url_2 entry = data_class_test.odds_trend() entry = crawl_engine.capture_matchesdata(webpage) database_conn.db_conn(entry)
import psycopg2 import crawl_engine import data_class_test def db_conn(d_entry): conn = psycopg2.connect(database='postgres',user='******',password='******',host= '54.186.47.255',options='-c statement_timeout=100') cur = conn.cursor() isql = "INSERT INTO _odds_trend(hname,aname,hodds,aodds,result,mtime,mnumber) VALUES(%s,%s,%s,%s,%s,%s,%s);" ssql = "INSERT INTO DD_table(matches,ddlist) VALUES(%s,%s);" cur.execute(isql,(d_entry.home_name,d_entry.away_name,str(d_entry.home_odds),str(d_entry.away_odds),d_entry.result,d_entry.match_time,d_entry.match_no)) ddlist = data_class_test.ddlist_restruct(d_entry) matches = d_entry.match_no cur.execute(ssql,(matches,ddlist)) conn.commit() cur.close() conn.close() webpage = 'http://211.151.108.43/soccer/match/742165/ah/handicap/27/' entry = data_class_test.odds_trend() entry = crawl_engine.capture_matchesdata(webpage) #db_conn(entry)