Home > Software engineering >  How to create a dialog box, realize read all links in the HTML file?
How to create a dialog box, realize read all links in the HTML file?

Time:09-21

Novice small white, hope to everyone's advice and help!

CodePudding user response:

Refer to the CDHtmlDialog

CodePudding user response:

Read the web page source code, pick all links

CodePudding user response:

Matching retrieval tag
CodePudding user response:


Web development is relatively easy to parse HTML dom. Such as phpquery
C/c + + even want to achieve, & lt; A href tag,

CodePudding user response:

https://blog.csdn.net/zhihu008/article/details/7922585

CodePudding user response:

 
Void EnumAnchorElement (IHTMLDocument2 * pIHTMLDocument2)//for embedded web page
{
if (! PIHTMLDocument2) return;
Retrieves the hr;

CComQIPtr SpAllElement;
Hr=pIHTMLDocument2 - & gt; Get_links (& amp; SpAllElement);//get all all embedded in the web page link
If (FAILED (hr))
return;

Long nLength=0;
SpAllElement - & gt; Get_length (& amp; NLength);
for (int i=0; I & lt; NLength; I++)
{
CComPtr PDisp;
Hr=spAllElement - & gt; The item (COleVariant (I) (long), COleVariant (0) (long), & amp; PDisp);//get a single link

If (SUCCEEDED (hr))
{
IHTMLElement * pEleme=NULL;
If (FAILED (pDisp - & gt; QueryInterface (IID_IHTMLElement, (void * *) & amp; PEleme)))
continue;

BSTR showText;
PEleme - & gt; Get_innerText (& amp; ShowText);
SysFreeString (showText);

//actual connection address
BSTR linkText;
PEleme - & gt; The toString (& amp; LinkText);
SysFreeString (linkText);

CComQIPtr & lt; IHTMLAnchorElement, & amp; IID_IHTMLAnchorElement & gt; PElement (pDisp);
BSTR bHref;
PElement - & gt; Get_href (& amp; BHref);
Cstrings strHref (bHref);
If (strHref cstrings=https://bbs.csdn.net/topics/=(" https://news.sina.com.cn/c/2018-10-22/doc-ifxeuwws6718927.shtml "))
{
PElement - & gt; Get_rel (& amp; BHref);
PElement - & gt; Get_rel (& amp; BHref);
break;
}
}
}
}

  • Related