Beispiel #1
0
def setValue(strs, begin, end):
    for i in range(begin, end):
        pattern = re.compile(r"《(.*)》")
        name = pattern.findall(strs[i])[0]
        if IsHaveTheMovie(name):
            continue
        # 正则匹配获取页面地址
        pattern = re.compile(r"href='(.*)'")  # 查找href链接地址
        url = pattern.findall(strs[i])[0]
        one = getMovieNameAndDownUrl(url)
        mysqlHelper.ExecuteSql(
            'insert into movie (url,`name`,`desc`,downurl,score) values ("%s","%s","%s","%s","%s")'
            % (one.url, one.name, one.desc, one.downUrl, one.score),
            connection)
def InsertPage(begin, end):
    pageSql = "insert into getpage(pageAll,pageIndex) values (" + \
        end + "," + begin + ")"
    lock.acquire()
    mysqlHelper.ExecuteSql(pageSql)
    lock.release()
Beispiel #3
0
def InsertPage(begin, end):
    pageSql = "insert into getpage(pageAll,pageIndex) values (" + \
        end + "," + begin + ")"
    mysqlHelper.ExecuteSql(pageSql)
Beispiel #4
0
import sys

if __name__ == '__main__':
    try:
        shopInfo = mysqlHelper.GetDb(
            'select id from shop where 1=1', 0, None, jd.connection)
        if shopInfo != None:
            ids = []
            # 获取商品Id合集
            for s in shopInfo:
                ids.append(str(s[0]))
                # 判断该物品的记录是否存在,不存在则增加
                shop = mysqlHelper.GetDb(
                    'select name from shop where id=%s', 1, s[0], jd.connection)
                if shop == None:
                    mysqlHelper.ExecuteSql('insert into shop (id,name,isSelf,businessman) values("%s","%s","%s","%s")' % (
                        id, jd.getName(id), 1, ''), jd.connection)
        # 获取价格
        prices = jd.getPrice(ids)
        # 时间(datetime类型)
        dt = time.strptime(time.strftime("%Y-%m-%d %H:%M:%S",
                                        time.localtime()), "%Y-%m-%d %H:%M:%S")
        # 多条插入时,使用的值
        pars = []
        for price in prices:
            par = (int(price['id'][2:]), float(price['p']), dt)
            pars.append(par)
        # 插入数据库
        mysqlHelper.ExecuteManySql(
            'insert into price (shopId,price,addtime) values("%s","%s",%s)', pars, jd.connection)
        # 遍历价格与通知表
        for price in prices:
Beispiel #5
0
		stops=GetLineStop(busId)
		i=1
		for stop in stops:
			 print('%d. 站点:%s' % (i,stop))
			 i=i+1
		stopPlace=[]
		line=input("请输入要记录的站点的序号,按-1取消输入:")
		while line!='-1':
			#判断是否输入的是数字
			stopPlace.append(stops[int(line)])
			print('已经记录%s' % (stops[int(line)]))
			line=input("请输入要记录的站点的序号,按-1取消输入:")
		#查询该车辆是否有记录 无则添加
		busInfo=mysqlHelper.GetDb('select * from businfo where guid="%s"' % (busId),1,None,connection)
		if busInfo==None:
			mysqlHelper.ExecuteSql('insert into busInfo (guid,name,arriveplace) values ("%s","%s","%s")' % (busId,busLine,overPlace),connection)
		#查询该车辆是否有记录位置  有则修改后保存
		busarriverecord=mysqlHelper.GetDb('select * from recordPlace where guid="%s"' % (busId),1,None,connection)
		if busarriverecord==None:
			mysqlHelper.ExecuteSql('insert into recordPlace (needrecordplace,guid) values ("%s","%s")' % (','.join(stopPlace),busId),connection)
		else:
			#判断是否已经记录过此站点,若记录过,则不再记录
			stopPlace=busarriverecord[1]+','+','.join(stopPlace)
			mysqlHelper.ExecuteSql('update recordPlace set needrecordplace="%s" where guid="%s"' % (stopPlace,busId),connection)
		line= input("请输入线路号,输入exit退出")

# 控制台程序
# if __name__ == '__main__':
#     paras = sys.argv[1].split('&')  # 用&分隔参数
#     if paras[0] == "GetLine":
#         result = GetLineInfo(paras[1])