网页代码我是用字符串保存的已经得到,使用的是MFC
<table width="100%" border="0" cellpadding="4" cellspacing="0" class="quotedata">
<tr align=right> <td alignf="/scripts/quoteisapi.dll?rank&type=4&sortfield=30&sorttype=0&begin=11&end=20" cla ="center"> <a href="/stock/exdir.aspx?target=RTQuote&code=000012&mk=2">南 玻A(000012)</a></td> <td> <font color="green"> 6.00 </font></td> <td><font color="green">-0.27</font></td> <td><font color="green"> -4.31%</font></td> <td><font color="black">0.00%</font></td> <td>2.23%</td> <td>1,574.21</td> <td>26,071</td> <td>53</td> <td>6.27</td> <td><font color="green"> 6.10</font></td> <td><font color="green"> 6.12</font></td> <td><font color="green"> 5.98</font></td> <td><font color="green"> 5.99</font></td> <td><font color="green"> 6.00</font></td> <td>10.21%</td> <td>1.23%</td> <td>9.98</td> <td>0.00%</td> </tr>
我现在只要取出里面的值和font color的值如南 玻A(000012),6.00 ,5.99。red,green,最好是给详细代码小弟基础很差。谢谢了等到立刻散分。
<table width="100%" border="0" cellpadding="4" cellspacing="0" class="quotedata">
<tr align=right> <td alignf="/scripts/quoteisapi.dll?rank&type=4&sortfield=30&sorttype=0&begin=11&end=20" cla ="center"> <a href="/stock/exdir.aspx?target=RTQuote&code=000012&mk=2">南 玻A(000012)</a></td> <td> <font color="green"> 6.00 </font></td> <td><font color="green">-0.27</font></td> <td><font color="green"> -4.31%</font></td> <td><font color="black">0.00%</font></td> <td>2.23%</td> <td>1,574.21</td> <td>26,071</td> <td>53</td> <td>6.27</td> <td><font color="green"> 6.10</font></td> <td><font color="green"> 6.12</font></td> <td><font color="green"> 5.98</font></td> <td><font color="green"> 5.99</font></td> <td><font color="green"> 6.00</font></td> <td>10.21%</td> <td>1.23%</td> <td>9.98</td> <td>0.00%</td> </tr>
我现在只要取出里面的值和font color的值如南 玻A(000012),6.00 ,5.99。red,green,最好是给详细代码小弟基础很差。谢谢了等到立刻散分。
你最好先查下以前的旧帖, 然后,有什么需要帮助的再进行提问.
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)));
}
}
}
注意头文件要这样加
#include <comdef.h>
#include <mshtml.h>
#pragma warning(disable : 4146) //see Q231931 for explaintation
#import <mshtml.tlb> no_auto_exclude
怎么办哦
应用的详细说明在下面的网页:
http://www.vckbase.com/document/viewdoc/?id=1446
// 所以声明它是必须的#include <mshtml.h> // 所有 IHTMLxxxx 的接口声明
#include <atlcom.h>这样包含头文件呢?