海上月明

          editer by sun
          posts - 162, comments - 51, trackbacks - 0, articles - 8
             :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理

          為pamie增加兩個有關獲取指定td、tr的函數

          Posted on 2013-06-07 14:59 pts 閱讀(697) 評論(0)  編輯  收藏 所屬分類: Python

           

              def getTdOfTableContains(self,table,conText):

                  #add 20130607 by sho

                  #find first td in table and td's innertext contains conText

                  for cell in table.cells:

                      if conText in cell.innertext:

                          return cell

                  return None

           

              def getTrOfTableContains(self,table,conText):

                  #add 20130607 by sho

                  #find first tr in table and tr's cells contains conText

                  td=self.getTdOfTableContains(table,conText)

                  if td:

                      return self.getElementParent(td)

                  else:

                      return None

          測試代碼:

           

          *** 遠程解釋器再初始化了  ***

          >>> from PAM30 import PAMIE

          >>> ie=PAMIE("http://1.1.1.1/query/itemQueryAction.do?method=jumpToSingleItemTrackQuery")

          >>> ie.setTextBox("itemno","1191590659011")

          True

          >>> ie.submitForm("itemQueryForm")

          True

          >>> tb4=ie.findElement("table","classname","table4")

          >>> tr_sj=ie.getTrOfTableContains(tb4,u"收寄")

          >>> print tr_sj.outerhtml

           

           

          主站蜘蛛池模板: 常州市| 潼关县| 长春市| 徐水县| 鹿泉市| 平定县| 榕江县| 淮阳县| 尖扎县| 北票市| 南丹县| 拉萨市| 汤原县| 龙海市| 泸溪县| 南康市| 武穴市| 荥阳市| 桓台县| 广元市| 漯河市| 望城县| 铜陵市| 荆门市| 饶河县| 寻甸| 海口市| 梅河口市| 安义县| 土默特左旗| 湘潭市| 宾阳县| 扬中市| 丹凤县| 永春县| 林周县| 大港区| 兴国县| 清流县| 贡觉县| 屏东县|