CodePudding user response:
Refer to the CDHtmlDialogCodePudding user response:
Read the web page source code, pick all linksCodePudding user response:
Matching retrieval tagWeb 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/7922585CodePudding user response:
Void EnumAnchorElement (IHTMLDocument2 * pIHTMLDocument2)//for embedded web page
{
if (! PIHTMLDocument2) return;
Retrieves the hr;
CComQIPtrSpAllElement;
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++)
{
CComPtrPDisp;
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;
}
}
}
}