本文整理汇总了Python中Helper.sql_escape方法的典型用法代码示例。如果您正苦于以下问题:Python Helper.sql_escape方法的具体用法?Python Helper.sql_escape怎么用?Python Helper.sql_escape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helper
的用法示例。
在下文中一共展示了Helper.sql_escape方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_messages
# 需要导入模块: import Helper [as 别名]
# 或者: from Helper import sql_escape [as 别名]
def get_messages(self, html, peoples):
status = 0
conversations = re.findall("<div class=\"c\">(.*?)</div>", html)
conversations = conversations[2:-3]
ret = []
for conversation in conversations:
msg = {}
tokens = re.findall(r'(.*?)<span', conversation)[0]
tokens = re.sub(r'<(?:.*?)>', '', tokens) # 去除html标记
tokens = re.sub(r'\[(在线|忙碌|离开)\]', '', tokens) # 去除在线标记
tokens = re.sub(r'\[\d+条新\]', '', tokens)
tokens = re.split(r':', tokens, 1)
people = tokens[0]
message = tokens[1]
time = re.findall(r'<span class="ct">(.*?)</span>', conversation)[0]
time = Helper.datetime_formater(time)
cnt_datetime = Helper.str2date(time)
if not cnt_datetime>self.last_time:
status = 1
return ret,status
if people == peoples[0]:
msg["dst"] = peoples[1]
else:
msg["dst"] = peoples[0]
msg["src"] = people
msg["message"] = Helper.sql_escape(message)
msg["time"] = time
ret.append(msg)
return ret, status
示例2: get_messages
# 需要导入模块: import Helper [as 别名]
# 或者: from Helper import sql_escape [as 别名]
def get_messages(self, html, peoples):
conversations = re.findall("<div class=\"c\">(.*?)</div>(?=<div class=\"(?:[cs])\"\>)", html)
conversations = conversations[2:-1]
ret = []
for conversation in conversations:
msg = {}
people = re.findall(r'<span class="cmt">(.*?)</span>', conversation)[0]
people = re.sub(r'<(?:.*?)>(.*?)</(?:.*?)>', lambda m: m.group(1), people)
people = re.sub(r'<(?:.*?)/>', '', people)
people = re.sub(r'[:]', '', people)
message = re.findall(r'(?:</span>)(.*?)(?=<span)', conversation)[0]
time = re.findall(r'<span class="ct">(.*?)</span>', conversation)[0]
if people == peoples[0]:
msg["dst"] = peoples[1]
else:
msg["dst"] = peoples[0]
msg["src"] = people
msg["message"] = Helper.sql_escape(message)
msg["time"] = time
ret.append(msg)
return ret