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:
|
for code in codes:
|
||||||
strItem=strItem.replace(code,"'")
|
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("'","'")
|
||||||
strItem=strItem.replace("???","'")
|
strItem=strItem.replace("???","'")
|
||||||
|
strItem=strItem.replace(""","\"")
|
||||||
return strItem
|
return strItem
|
||||||
|
|
||||||
def pad(str,filler,length):
|
def pad(str,filler,length):
|
||||||
|
|||||||
39
utility.py
39
utility.py
@@ -26,29 +26,34 @@ class StringHelper:
|
|||||||
def betweenString(strItem, strBegin, strEnd):
|
def betweenString(strItem, strBegin, strEnd):
|
||||||
if strItem is None:
|
if strItem is None:
|
||||||
return None
|
return None
|
||||||
index=-1
|
index = -1
|
||||||
if strBegin is None:
|
if strBegin is None:
|
||||||
index=0
|
index = 0
|
||||||
else:
|
else:
|
||||||
index = strItem.index(strBegin)
|
try:
|
||||||
if -1==index:
|
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
|
return None
|
||||||
str=None
|
str = strItem[index:] if strBegin is not None else strItem
|
||||||
if strBegin is not None:
|
|
||||||
str=strItem[index+len(strBegin):]
|
|
||||||
else:
|
|
||||||
str=strItem
|
|
||||||
if strEnd is None:
|
if strEnd is None:
|
||||||
return str
|
return str
|
||||||
index=str.index(strEnd)
|
try:
|
||||||
if -1==index :
|
index = str.index(strEnd)
|
||||||
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
sb=""
|
sb = ""
|
||||||
for strIndex in range(0, len(str)-1):
|
for strIndex in range(0, len(str) - 1):
|
||||||
if index==strIndex:
|
if index == strIndex:
|
||||||
break
|
break
|
||||||
sb=sb+str[strIndex]
|
sb = sb + str[strIndex]
|
||||||
return (sb)
|
return sb
|
||||||
|
|
||||||
class HttpNetRequest:
|
class HttpNetRequest:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -122,8 +127,6 @@ class DateTimeHelper:
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# returns a datetime
|
# returns a datetime
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def applyRelativeTime(sometime,relativetime):
|
def applyRelativeTime(sometime,relativetime):
|
||||||
|
|||||||
Reference in New Issue
Block a user