例如:
CString sjk="http://www.csdn.net 程序员网站 http://csdn.net sdfd www.csdn.net"提取出http://www.csdn.net
http://csdn.net
www.csdn.net
CString sjk="http://www.csdn.net 程序员网站 http://csdn.net sdfd www.csdn.net"提取出http://www.csdn.net
http://csdn.net
www.csdn.net
解决方案 »
- 在sourceforge上面下载的代码,无工程文件”或“解决方案”,哪位指点一下怎么使用啊
- 高分求DCOM通信问题
- C/S下遇到的问题
- 如何使对话框产生阴影效果?
- 急急急!在线等,懂汇编和C++的啊?
- 校验和问题……
- No mapping between account names and security IDs was done.调用GetLastError,显示这个错误,怎么解决
- 请教:如何在Frame类、视图类与文档类之间相互引用对方?
- 为什么socket赋值不上去?
- 大虾,救命啊!6000人民币快没了!要多少分给多少!
- 求助WIN32程序。
- 救命呀!!!再次求助ISAPI 通过post获取表单对象的问题
LPBC pBC,
LPCWSTR szURL,
DWORD dwReserved
);ParameterspBC
[in] Address of the IBindCtx interface. This parameter is optional and is currently ignored. It should be set to NULL.
szURL
[in] Address of a string value that contains the full URL to be checked.
dwReserved
[in] Reserved for future use. This must be set to zero.
Return ValueReturns one of the following values:S_OK The szURL parameter contains a valid URL.
S_FALSE The szURL parameter does not contain a valid URL.
E_INVALIDARG One of the parameters is invalid. Function Information
<a
href="http://www.dameiprinting.com/dz/feedback.htm">
<A
href="http://www.dameiprinting.com/dz/toc.htm">
<A href="http://www.dameiprinting.com/dz/search.htm"><A language=JavaScript
onmouseover="if(MSFPhover) document['MSFPnav1'].src=MSFPnav1h.src"
onmouseout="if(MSFPhover) document['MSFPnav1'].src=MSFPnav1n.src"
href="http://www.dameiprinting.com/dz/products.htm">
<A
target="_blank" href="http://www.dameiprinting.com/"><A href="mailto:[email protected]"><!--webbot<A
href="mailto:[email protected]">
<A
href="mailto:[email protected]">
<A
href="http://www.dameiprinting.com/dz/products.htm"
target="">斑竹,请用strstr把上述的url连接提取出来,不要email!
看看那个什么OnBGo函数。void CTestDlg::OnBbrowse() //打开html文件
{
UpdateData();
CFileDialog fdlg(TRUE, NULL, NULL, OFN_HIDEREADONLY|OFN_FILEMUSTEXIST,
_T("HTML Files (*.html; *.htm)|*.html;*.htm|All Files (*.*)|*.*||"), this);
if (fdlg.DoModal() == IDOK) {
m_csFilename = fdlg.GetPathName();
UpdateData(FALSE);
}
}void CTestDlg::OnBgo()
{
UpdateData();
CWaitCursor wait;
if(m_csFilename.IsEmpty()){
AfxMessageBox(_T("Please specify the file to parse"));
return;
}
CFile f; //let's open file and read it into CString (u can use any buffer to read though
if (f.Open(m_csFilename, CFile::modeRead|CFile::shareDenyNone)) {
m_wndLinksList.ResetContent();
CString csWholeFile;
f.Read(csWholeFile.GetBuffer(f.GetLength()), f.GetLength());
csWholeFile.ReleaseBuffer(f.GetLength());
f.Close(); //declare our MSHTML variables and create a document
MSHTML::IHTMLDocument2Ptr pDoc;
MSHTML::IHTMLDocument3Ptr pDoc3;
MSHTML::IHTMLElementCollectionPtr pCollection;
MSHTML::IHTMLElementPtr pElement; HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IHTMLDocument2, (void**)&pDoc);
//put the code into SAFEARRAY and write it into document
SAFEARRAY* psa = SafeArrayCreateVector(VT_VARIANT, 0, 1);
VARIANT *param;
bstr_t bsData = (LPCTSTR)csWholeFile;
hr = SafeArrayAccessData(psa, (LPVOID*)¶m);
param->vt = VT_BSTR;
param->bstrVal = (BSTR)bsData;
hr = pDoc->write(psa);
hr = pDoc->close();
SafeArrayDestroy(psa); //I'll use IHTMLDocument3 to retrieve tags. Note it is available only in IE5+
//If you don't want to use it, u can just run through all tags in HTML
//(IHTMLDocument2->all property)
pDoc3 = pDoc;
//display HREF parameter of every link (A tag) in ListBox
pCollection = pDoc3->getElementsByTagName(L"A");
for(long i=0; i<pCollection->length; i++){
pElement = pCollection->item(i, (long)0);
if(pElement != NULL){
//second parameter says that you want to get text inside attribute as is
m_wndLinksList.AddString((LPCTSTR)bstr_t(pElement->getAttribute("href", 2)));
}
}
}
}
http://www.boost.org/libs/regex/
这个地方说的很清楚,我的代码就是从那边找过去的,我已经运行测试了结果,很正确,和你需要不同的是他从硬盘上读网页内容到内存,而你的内容已经存在内存中了,codeproject需要注册邮箱地址,你注册一下就能下载了,如果嫌麻烦,赶快把邮箱贴出来,我给你发过去。
结帖!