Fix parsing of <time> tag and add extra handling for html tags.
This commit is contained in:
@@ -258,10 +258,12 @@ class Sections:
|
||||
for code in codes:
|
||||
strItem=strItem.replace(code,"'")
|
||||
strItem=strItem.replace("&","&")
|
||||
strItem=strItem.replace("‘","'")
|
||||
strItem=strItem.replace("’","'")
|
||||
strItem=strItem.replace("‘","‘")
|
||||
strItem=strItem.replace("’","’")
|
||||
strItem=strItem.replace("—","-")
|
||||
strItem=strItem.replace("'","'")
|
||||
strItem=strItem.replace("???","'")
|
||||
strItem=strItem.replace(""","\"")
|
||||
return strItem
|
||||
|
||||
def pad(str,filler,length):
|
||||
|
||||
39
utility.py
39
utility.py
@@ -26,29 +26,34 @@ class StringHelper:
|
||||
def betweenString(strItem, strBegin, strEnd):
|
||||
if strItem is None:
|
||||
return None
|
||||
index=-1
|
||||
index = -1
|
||||
if strBegin is None:
|
||||
index=0
|
||||
index = 0
|
||||
else:
|
||||
index = strItem.index(strBegin)
|
||||
if -1==index:
|
||||
try:
|
||||
if strBegin.startswith("<") and strBegin.endswith(">"):
|
||||
tag_name = strBegin[1:-1] # e.g. "time"
|
||||
index = strItem.index("<" + tag_name)
|
||||
index = strItem.index(">", index) + 1
|
||||
else:
|
||||
index = strItem.index(strBegin) + len(strBegin)
|
||||
except ValueError:
|
||||
return None
|
||||
if index == -1:
|
||||
return None
|
||||
str=None
|
||||
if strBegin is not None:
|
||||
str=strItem[index+len(strBegin):]
|
||||
else:
|
||||
str=strItem
|
||||
str = strItem[index:] if strBegin is not None else strItem
|
||||
if strEnd is None:
|
||||
return str
|
||||
index=str.index(strEnd)
|
||||
if -1==index :
|
||||
try:
|
||||
index = str.index(strEnd)
|
||||
except ValueError:
|
||||
return None
|
||||
sb=""
|
||||
for strIndex in range(0, len(str)-1):
|
||||
if index==strIndex:
|
||||
sb = ""
|
||||
for strIndex in range(0, len(str) - 1):
|
||||
if index == strIndex:
|
||||
break
|
||||
sb=sb+str[strIndex]
|
||||
return (sb)
|
||||
sb = sb + str[strIndex]
|
||||
return sb
|
||||
|
||||
class HttpNetRequest:
|
||||
def __init__(self):
|
||||
@@ -122,8 +127,6 @@ class DateTimeHelper:
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
# returns a datetime
|
||||
@staticmethod
|
||||
def applyRelativeTime(sometime,relativetime):
|
||||
|
||||
Reference in New Issue
Block a user