海上月明

          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

           

           

          主站蜘蛛池模板: 崇仁县| 珲春市| 沧州市| 巍山| 吉林省| 嘉义市| 怀化市| 江华| 治多县| 河曲县| 萝北县| 正镶白旗| 东源县| 高唐县| 南江县| 濮阳市| 朝阳县| 德令哈市| 雷波县| 勃利县| 昆明市| 黄石市| 南平市| 米泉市| 赫章县| 阿巴嘎旗| 谢通门县| 赣榆县| 叙永县| 塔城市| 淳安县| 碌曲县| 彩票| 辽源市| 安陆市| 方城县| 崇阳县| 封开县| 剑阁县| 崇左市| 黄梅县|