精品伊人久久大香线蕉,开心久久婷婷综合中文字幕,杏田冲梨,人妻无码aⅴ不卡中文字幕

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
Delphi TWebBrowser[6] 獲取網頁所有鏈接(元素)、下拉菜單及GetElementByID返回值的有效性判定方法
userphoto

2022.10.31 湖南

關注

1、獲取網頁所有鏈接

var

  elem: IHTMLElement;

  coll: IHTMLElementCollection;

  i: integer;

  url, title: string;

begin

  coll := (WebBrowser1.Document as IHTMLDocument2).all;

  coll := (coll.tags('a') as IHTMLElementCollection);

  for i := 0 to coll.Length - 1 do

  begin //   循環取出每個鏈接

    elem := (coll.item(i, 0) as IHTMLElement);

    url := Trim(string(elem.getAttribute(WideString('href'), 0)));

    title := elem.innerText;

    ShowMessage(Format('鏈接標題:%s,鏈接網址:%s', [title, url]));

  end;

end;


其他元素的獲取,方法類似

-----------------------------------

Delphi TWebBrowser[6] 獲取網頁所有鏈接(元素)、下拉菜單及GetElementByID返回值的有效性判定方法

https://blog.51cto.com/u_15069471/4024964

下拉菜單

uses MsHtml;

var

  doc: IHTMLDocument2;

  coll: IHTMLElementCollection;

  iPos, iIndex: Integer;

  selElem: IHtmlSelectElement;

  optElem: IHtmlOptionElement;

begin

  doc := WebBrowser1.Document as IHTMLDocument2;

  if doc = nil then Exit;

  coll := doc.all.tags('select') as IHTMLElementCollection;

  iPos := 0; //要訪問的下拉菜單的序號,從0開始為第一個

  selElem := coll.item(iPos, 0) as IHtmlSelectElement;

  if selElem = nil then Exit;

  iIndex := 2; //下拉菜單的選項序號,從0開始為第一個,2為第三個選項

  optElem := selElem.item(iIndex, 0) as IHtmlOptionElement;

  if optElem = nil then Exit;

  ShowMessage(optElem.text); //獲取該選項的值

  optElem.selected := True;  //選中該選項

end; 

-----------------------------------

Delphi TWebBrowser[6] 獲取網頁所有鏈接(元素)、下拉菜單及GetElementByID返回值的有效性判定方法

https://blog.51cto.com/u_15069471/4024964

GetElementByID返回值有效性判定方法

var

  aElement: OleVariant;

begin

  aElement := WebBrowser1.OleObject.Document.GetElementByID('btnLogin');

  if IDispatch(aElement) <> nil then //對返回值進行有效性檢查

  begin

    aElement.value := '登錄按鈕';

    aElement.click;

  end;

end;

-----------------------------------

Delphi TWebBrowser[6] 獲取網頁所有鏈接(元素)、下拉菜單及GetElementByID返回值的有效性判定方法

https://blog.51cto.com/u_15069471/4024964

本站僅提供存儲服務,所有內容均由用戶發布,如發現有害或侵權內容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Excel分類,設定下拉菜單
WORD的數據有效性怎么破?
Excel聯想有效性設置,下拉菜單更科學,工作超輕松
Articles
javascript實現動態多附件上傳方法
職場新技能:Excel中設置下拉菜單
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點擊這里聯系客服!

聯系客服

主站蜘蛛池模板: 岢岚县| 普兰店市| 昌乐县| 怀仁县| 原平市| 阿合奇县| 上高县| 锦屏县| 玛纳斯县| 马公市| 泰和县| 岑巩县| 永仁县| 右玉县| 河间市| 滨州市| 嘉黎县| 本溪| 安吉县| 吴川市| 兰州市| 望都县| 鄢陵县| 绥江县| 印江| 宁武县| 台中市| 丹东市| 抚松县| 兖州市| 雅江县| 华亭县| 曲阳县| 白河县| 岳普湖县| 东安县| 荔浦县| 平南县| 颍上县| 景泰县| 平远县|