哈哈強大的查詢元素函式

2021-09-25 22:23:37 字數 3254 閱讀 3993

// 1 相同,2 包含 ,3不包含 4 不等於 21 上級元素相同,22 上級元素包含 ,23 上級元素不包含 24 上級元素不等於 -1 下級元素相同,-2 下級元素包含 ,-3 下級元素不包含 -4 下級元素不等於, -5 沒有下級元素

//31 上兄弟元素相同,32 上兄弟元素包含 ,33上兄弟元素不包含 34 兄弟上元素不等於,35 沒有上兄弟元素,41 下兄弟元素相同,42 下兄弟元素包含 ,43下兄弟元素不包含 44 下兄弟元素不等於 ,45 沒有下兄弟元素

//arpmatchreg為trim時表示trim匹配 其它為正則

//使用object主要是不想讓this成為全域性變數 meo.getelementsbyattrs(「a」,「title」,「pdf」,2,"",「a」,「href」,"/pdf/",2,"")[0] 如果要不包含標籤文字(用43等) tag應該定義為』』

"p","outerhtml","",2,"","div","id","a",21,/\d/g,"a","outerhtml",""p","outerhtml","var

meo=

elseif(

[21,22

,23,24

,25].

includes

(argu3)

&& aelements[i]

.parentelement!=

null

)elseif(

[31,32

,33,34

,35].

includes

(argu3)

&& aelements[i]

.previouselementsibling!=

null

)elseif(

[41,42

,43,44

,45].

includes

(argu3)

&& aelements[i]

.nextelementsibling!=

null

)elseif(

[-1,

-2,-

3,-4

,-5]

.includes

(argu3)

&& aelements[i]

.firstelementchild!=

null

)'argu3: '+argu3+ '---ifnoe: '+ifnoe); // if(

!ifnoe)

if(atrarr.

indexof

(argu1)

>=0)

else

}else;if

(!this

['attr'

+j+'v'])

//如果沒有該元素值,直接退出,要不然為undefined時下面替換會出錯

if(argu4 ==

'trim'

)else

if(argu4!='')

i + ':--' +j+': ---attr'+j+ 'v:'+this['attr'+j+ 'v'] +'---value:'+ argu2); if(

this

['aelem'

+j].tagname.

tolowercase()

== argu0.

tolowercase()

|| argu0=='')

elseif(

(argu3.

tostring()

.slice(-

1)=='2')&&

(this

['attr'

+j+'v']!=

null)&&

(this

['attr'

+j+'v'].

includes

(argu2)))

elseif(

(argu3.

tostring()

.slice(-

1)=='3')&&

(this

['attr'

+j+'v']!=

null)&&

!(this

['attr'

+j+'v'].

includes

(argu2)))

elseif(

(argu3.

tostring()

.slice(-

1)=='4')&&

(this

['attr'

+j+'v']!=

null)&&

(this

['attr'

+j+'v']!=

(argu2)))

}if(!

this

['ifmatch'

+j])

i + ':--' +j+': ---attr'+j+ 'v:'+this['attr'+j+ 'v'] +'---value'+ j+':'+ argu2 +'this["ifmatch"+j]:'+this['ifmatch'+j] +'---ifthise:'+ ifthise +' --this["aelem"+j]outerhtml: '+ this['aelem'+j].outerhtml);

'argu3.tostring().slice(-1)=="3"'+ argu3.tostring().slice(-1) + '---' +this['attr'+j+ 'v']+ '---' + (argu2) + this['attr'+j+ 'v'].includes(argu2));

}else

// !ifnoe

else

//如果沒有該元素,說明符合條件

}//if (this['aelem'+j] ) else

}//jif

(this

['ifmatch'

+(keynum-1)

])//if( ifthise )

}//ireturn aeles;

}else

}}

呼叫: meo.getelementsbyattrs(『h3』,『class』,『t1』,3,』』,『h3』,『class』,『t』,2,『trim』,『h3』,『class』,『t』,1,/4/g)

注:要想相容ie,可將includes換成indexof;

使用meo主要是不願意this成為全域性變數。

getelementsbyattrs 當然可以用簡單的字串啦,比如 $代替以簡化** var meo =

強大的sscanf函式

int sscanf const char buffer,const char format,argument buffer 儲存的資料 format 格式控制字串。argument 可選自變數 sscanf sscanf與scanf類似,都是用於輸入的,只是後者以鍵盤 stdin 為輸入源,前者以...

Python強大的函式

python的函式比c語言 c 函式更加靈活與強大 函式,無返回值 def show s print welcome s show hello 函式,有乙個返回值 def sum a,b return a b print sum 111,222 函式,返回的是tuple元組 好像返回多個值 def ...

強大的ackermann函式

演算法老師給我們布置的兩道題拖了幾天了,今天決定搞定它們。其中有一道就是 計算ackermann函式ack m,n 的遞迴計算函式。對於m 0,n 0,ack m,n 定義為 ack 0,n n 1 ack m,0 ack m 1,1 ack m,n ack m 1,ack m,n 1 對著題目看了...