imは訪問したサイトからすべての画像をダウンロードする小さなツールを作ろうとしています。 twebbrowserコンポーネントで作成する必要があります。私の顧客のテストサイトはClickです。現時点では、imはgetelementbyidで写真を選択していますが、写真のいくつかはIDを持っていません。どのように私は行方不明のものに対処できますか?ありがとうalottwebbrowserでdelphiのウェブサイトから画像を掻き集める
答えて
ページはIHTMLDocument2
インタフェースのためのTWebBrowser.Document
プロパティを照会、ロードされ、その後、あなたがIHTMLDocument2.images
コレクションの要素を列挙することができた後:これが唯一の画像を見つけること
var
Document: IHTMLDocument2;
Images: IHTMLElementCollection;
Image: IHTMLImgElement;
I: Integer;
begin
Document := WebBrowser1.Document as IHTMLDocument2;
Images := Document.images;
For I := 0 to Images.length - 1 do
begin
Image := Images.item(I, '') as IHTMLImgElement;
// use Image as needed...
end;
end;
は注意をHTML <img>
タグ。あなたが同様に<input type="image">
タグで画像を検索する必要がある場合は、type
財産例えば、"image"
あるIHTMLInputElement
インターフェースのインスタンスを探してIHTMLDocument2.all
コレクションの要素を列挙しなければなりません。
var
Document: IHTMLDocument2;
Elements: IHTMLElementCollection;
Element: IHTMLElement;
Image: IHTMLImgElement;
Input: IHTMLInputElement;
I: Integer;
begin
Document := WebBrowser1.Document as IHTMLDocument2;
Elements := Document.all;
For I := 0 to Elements.length - 1 do
begin
Element := Elements.item(I, '') as IHTMLElement;
if Element is IHTMLImgElement then begin
Image := Element as IHTMLImgElement;
// use Image as needed...
end
else if Element is IHTMLInputElement then begin
Input := Element as IHTMLInputElement;
if Input.type = 'image' then
begin
// use Input as needed...
end;
end;
end;
end;
idで特定の要素を要求する代わりに、WebDocument.all.item(itemnum、 '')を使用して文書を「ウォーク」して各要素を表示できます。
var
cAllElements: IHTMLElementCollection;
eThisElement: IHTMLElement;
WebDocument: IHTMLDocument2;
=======
cAllElements:=WebDocument.All
For iThisElement:=0 to cAllElements.num-1 do
begin
eThisElement:=cAllElements.item(iThisElement,'') as IHTMLElement;
// check out eThisElement and do what you want
end;
あなたはその後、IMGのための要素.tagNameを見て、またはあなたはそれが絵であるかどうかを判断して処理するために必要なものは何でも評価するだろう以前と同じように
ダン
文書の 'images'コレクションを歩くことは、' all'コレクションを歩くよりも簡単です。 –
私は同意します。私は画像コレクションを忘れていた。いずれもうまくいくが、画像コレクションを使用する方がより簡単だろう。 .allコレクションは、アドホック検索にもっと役立ちます。 –
- 1. シングルページのウェブサイトを掻き集める
- 2. python3&beautifulsoup 4で掻き集めるウェブサイト
- 3. 電子メールでウェブサイトからhtmlタグを掻き集める
- 4. PythonでウェブサイトからHTMLデータを掻き集める
- 5. Rを使用してaspxウェブサイトから掻き集める
- 6. 画面のデータベースを掻き集める
- 7. ローカルに読み込まれた画像を掻き集める
- 8. ASP.NETベースのウェブサイトのコンテンツをスクラップで掻き集める
- 9. ビデオリンク用の購読済みのウェブサイトを掻き集める
- 10. ウェブサイトの特定の部分を掻き集める[Python]
- 11. Python 2を使用してウェブサイトからデータを掻き集める
- 12. Beaufifulsoupとリクエストを使用してウェブサイトからコンテンツを掻き集める
- 13. テキストファイルから変数を使用してPythonウェブサイトを掻き集める
- 14. ウェブサイト特定のフォームを掻き集める
- 15. PythonでSeleniumでjavascriptを注入した画像を掻き集める
- 16. python 2.7とbeautifulsoup 4で掻き集めるウェブサイト
- 17. ノードを掻き集める
- 18. Pythonを掻き集める
- 19. VIEWSTATEを掻き集める
- 20. Netflixを掻き集める
- 21. ポストリクエストを使用してRubyを掻き集めるウェブサイト
- 22. twebbrowser delphiのコールバック
- 23. Google AnalyticsをScrapで掻き集める
- 24. Pythonでテーブルを掻き集めるWeb
- 25. jsonをPythonリクエストで掻き集める
- 26. WebをPython 3で掻き集める
- 27. beautifulsoupでウェブを掻き集める
- 28. Phantomjsでサイトを掻き集める
- 29. Node.js画像を掻き集めて変換するsrc - >完全なURL
- 30. Beautifulsoup掻き集め本カタログ
作業DOMを通じて探し画像 –