티스토리 뷰

SWDesk

[Python] PickNewItems - TreatPage()

inhae 2022. 5. 29. 02:21

 

 

    def TreatPage(self, webDriver, paramIn, pageNo=None):
        # Treating page ...
        tagProperty = paramIn.get('TagProperty')
        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')
        startPageNo = paramIn.get('StartPage')

        if not startPageNo: startPageNo = 1

        if not pageNo:
            pageNo = startPageNo

        elem0 = self.GetElement(webDriver, tagType, tagValue)
        if str(type(subTags))=="<class 'list'>":
            for subTag in subTags:
                tagType1 = subTag['TagType']
                tagValue1 = subTag['TagValue']
                elems1 = self.GetElements(elem0, tagType1, tagValue1)
                for elem1 in elems1:
                    try:
                        num1 = int(elem1.text)
                    except Exception as e:
                        continue
                    if num1==pageNo:
                        elem1.click()
                        webDriver.implicitly_wait(5) # delay
                        return webDriver
        elif str(type(subTags))=="<class 'dict'>":
            tagType1 = subTag['TagType']
            tagValue1 = subTag['TagValue']
            elems1 = self.GetElements(elem0, tagType1, tagValue1)
            for elem1 in elems1:
                try:
                    num1 = int(elem1.text)
                except Exception as e:
                    continue
                if num1==pageNo:
                    elem1.click()
                    webDriver.implicitly_wait(5) # delay
                    return webDriver
        else:
            print("[?] Wrong Type of SubTags")
            return None

        return None
반응형

'SWDesk' 카테고리의 다른 글

[Python] Send Email through Outlook  (0) 2022.06.03
[Python] Testing ... DataFrame  (0) 2022.05.31
[Python] PickNewItems - TreatSubTag()  (0) 2022.05.28
[Python] PickNewItems - GetItemValue()  (0) 2022.05.26
[Python] Data Addition after Initialization  (0) 2022.05.23