網頁資訊格式化方法GetAttribute

2021-06-02 20:26:41 字數 1175 閱讀 9303

以前格式化網頁或者資訊提取一般都用的是正則;昨天由於網頁資訊用正則實現起來太麻煩而且易出錯所以改用webbrowser 然後利用getattribute來實現資訊的格式化

htmlelementcollection tables = webbrowser.document.getelementsbytagname("table");

tryif (tables[x].getattribute("width") == "100%" && tables[x].getattribute("cellpadding") == "4" && tables[x].getattribute("cellspacing") == "1")

}catch

}string sarray = new string[15];

string sarray2 = new string[14];

sarray2[0] = "business";

sarray2[1] = "year";

sarray2[2] = "products";

sarray2[3] = "website";

sarray2[4] = "bankers";

sarray2[5] = "standard";

sarray2[6] = "products";

sarray2[7] = "services";

sarray2[8] = "company";

sarray2[9] = "address";

sarray2[10] = "phone";

sarray2[11] = "fax";

sarray2[12] = "contact";

sarray2[13] = "mobile";

for (int i = 1; i < table1.getelementsbytagname("tr").count; i++)}}

}for (int m = 0; m < table2.getelementsbytagname("tr").count-1; m++)

if (table2.getelementsbytagname("tr")[m].getelementsbytagname("td").count==2)}}

}sarray[14] = id;

addcominfo(sarray);

日期格式化方法

date型別有一些專門用於將日期格式化為字串的方法 1 todatestring 以特定的於實現的格式顯示星期幾 年月日。2 totimestring 以特定的於實現的格式顯示時分秒和時區。3 tolocaledatestring 以特定於地區的格式顯示星期幾 年月日。4 tolocaltimest...

格式化,強調 數值格式化

聚合函式返回的的數值型別的值有個特點就是沒有被格式化。通過前面的帶 sum 聚合函式的示例,我們可以看到這一點 注意合計值 命令,或者在物件檢視器中選中 displayformat 屬性。在上節的示例中,格式化操作是針對一物件或物件內的表示式,在物件內僅有乙個表示式時它還能正常工作,不過當物件內不有...

js 格式化金額方法

金額千分位加逗號,保留2位小數,不足補零,否則四捨五入 引數說明 num 要格式化的數字 string或者number decimals 保留幾位小數 dec point 小數點符號 thousandssep 千分位符號 return 金額格式的字串,如 1,234,567.45 number nu...