티스토리 뷰
def GetItemValue(self, elemIn, paramIn):
# paramIn : ItemValue or ValueTag : {‘TagProperty’, ‘TagType’, ‘TagValue’, ‘valueTag_s’, [‘Attribute’]}
tagType = paramIn.get('TagType')
tagValue = paramIn.get('TagValue')
tagProperty = paramIn.get('TagProperty')
valueID = paramIn.get('ValueID')
attrib = paramIn.get('Attribute')
subTags = paramIn.get('SubTag_s')
valueTags = paramIn.get('ValueTag_s')
rst1 = {}
if valueID: # tagProperty == "aValue"
elem1 = self.GetElement(elemIn, tagType, tagValue)
if not elem1:
return
if not attrib:
rst1[valueID] = elem1.text
elif attrib=="text":
#print("[elem1]", str(elem1))
rst1[valueID] = elem1.text
else:
rst1[valueID] = elem1.get_attribute(attrib)
#print("[text]", elem1.get_attribute('innerHTML'))
return rst1
if subTags:
rst1DF = DataFrame()
elem1 = self.GetElement(elemIn, tagType, tagValue)
if str(type(subTags))=="<class 'list'>":
for subTag in subTags:
res1 = self.GetItemValue(elem1, subTag)
if not res1.empty:
#print("[res1]", res1)
if rst1DF.empty: rst1DF = DataFrame(res1)
else: rst1DF = rst1DF.append(res1, ignore_index=True)
elif str(type(subTags))=="<class 'dict'>":
res1 = self.GetItemValue(elem1, subTags)
if not res1.empty:
#print("[res1]", res1)
if rst1DF.empty: rst1DF = DataFrame(res1)
else: rst1DF = rst1DF.append(res1, ignore_index=True)
else:
print("[?] Wrong Type of SubTags")
return rst1DF
if tagProperty=="ItemValue":
if not valueTags:
print("[?] None of ValueTags")
return
for valueTag in valueTags:
try:
res1 = self.GetItemValue(elemIn, valueTag)
if res1:
#print("[res1]", res1)
if rst1: rst1.update(res1)
else: rst1 = res1.copy()
except Exception as e:
print("[???] ", str(e))
continue
return DataFrame([rst1])
elif tagProperty=="ItemValues":
elems1 = self.GetElements(elemIn, tagType, tagValue)
for elem11 in elems1:
for valueTag in valueTags:
try:
res1 = self.GetItemValue(elemIn, valueTag)
if res1:
#print("[res1]", res1)
if rst1: rst1.update(res1)
else: rst1 = res1.copy()
except Exception as e:
print("[???] ", str(e))
continue
return DataFrame([rst1])
return DataFrame()
반응형
'SWDesk' 카테고리의 다른 글
[Python] PickNewItems - TreatPage() (0) | 2022.05.29 |
---|---|
[Python] PickNewItems - TreatSubTag() (0) | 2022.05.28 |
[Python] Data Addition after Initialization (0) | 2022.05.23 |
[Python] Stock Trade (0) | 2022.04.12 |
BStockTrade - DataManager (1) | 2022.03.15 |
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 오블완
- 전류
- 전압전류모니터링
- Innovations
- Hurdles
- 배프
- Video
- 심심풀이치매방지기
- 전압
- Innovations&Hurdles
- badp
- Innovation&Hurdles
- 티스토리챌린지
- 둎
- 심심풀이
- 절연형
- 치매
- 치매방지
- 혁신과허들
- 혁신
- BSC
- 허들
- ServantClock
- Decorator
- image
- 빌리언트
- arduino
- DYOV
- bilient
- 아두이노
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
글 보관함