我用perl写过,你在google用lwp找,会用c++的code 

解决方案 »

  1.   

    我的做法:
    1):FILE*  以TXT格式读入到内存。
    2): strncmp(str1, "<a>")感觉不太好,不过能用
      

  2.   

    你是不是想做一个html的编译器了
      

  3.   

        操作 IHTMLDocument2 ..... 等等接口,用 oleView 查查 mshtml.tlb ,东东满多的(生成的mshtml.tlh 有 100K 行啊,看的累死了),用起来也方便。
        其实用 VB 方便些,就用 javascript + 自己写两个 组件 轻松搞定。不用自己去分析 什么 html 语法了。
      

  4.   

    MSDN中就有例子吗?不要遇到问题就问(和我以前一样)不然学不到东西的!去找找资料自己研究研究,你会有收获的!!
      

  5.   

    see walkall sample in MSDN
      

  6.   

    自己整理吧
    可以运行的代码// list_url.cpp : Defines the entry point for the console application.
    //#include "stdafx.h"
    #include "list_url.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endifBOOL FindHref(LPCTSTR lpszFind,LPCTSTR lpszString,CString& lpszResult,UINT nLen)
    {
    // start the search at nStart
    LPCTSTR lpsz = lpszFind; // single-byte string search
    UINT nCompare = nLen;
    int k=0;
    int nLenFind = lstrlen(lpszString);
    lpszResult ="";
    while (nCompare > 0)
    { LPSTR lpch = (LPSTR)(lpsz + nLenFind);
    char chSave = *lpch;
    *lpch = '\0';
    int nResult = lstrcmpi(lpsz, lpszString);
    *lpch = chSave;
    if (nResult == 0)
    {
    while(*lpsz != '\0')
    {
    if(*lpsz =='"')
    {
    lpsz++;
    k++;
    int j=0;
    while(*lpsz != '"')
    {
    lpszResult += lpszFind[k+j];
    lpsz++;
    j++; }
    return TRUE; }
    lpsz++;
    k++;
    } return TRUE;
    } // restore character at end of search
    *lpch = chSave; // move on to next substring
    nCompare--;
    lpsz ++;
    k++;
    } return FALSE;
    }//BOOL GetHref(LPCSTR szBuffer,LPCSTR szfind, CStringList& list)
    BOOL GetHref(LPCSTR szBuffer,LPCSTR szfind, CStringList& RList)
    {
    BOOL InTag=FALSE;
    // CStringList RList;
    int i = 0,j=0;
    POSITION pos = NULL;
    int nLen = strlen(szBuffer);
    LPCTSTR lpsz = szBuffer;
    if( nLen <= 0) return FALSE;

    CString str,hString;
    str="";
    while (nLen)
    {
    if( *lpsz == '<') InTag=TRUE;

    if(InTag==TRUE) str += szBuffer[j];

    if( *lpsz == '>')  
    {
    RList.AddTail(str);
    str ="";
    InTag=FALSE;
    }

    ++lpsz;
    j++;
    nLen--;

    } return TRUE;
    }
    /////////////////////////////////////////////////////////////////////////////
    // The one and only application objectCWinApp theApp;using namespace std;int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
    {
    int nRetCode = 0; if(argc < 2)
    {
    cout << "Usage: myname inputfilename" << endl;
    return nRetCode;
    } try
    {
    CFile f( argv[1], CFile::modeRead );
    long l = f.GetLength();
    char* p = new char[l+1];
    f.Read(p, l);
    p[l] = 0;

    CStringList list;
    BOOL found=FALSE; found= GetHref(p, _T("href"), list);
    int count = list.GetCount();
    POSITION pos=NULL;
    CString str, rString=""; if(found==TRUE && count>0)
    {
    for(int i=0; i<count; i++)
    {
    if( ( pos = list.FindIndex( i)) != NULL )
    {
    str = list.GetAt( pos );
    cout << (i+1) << "\t"<< (LPCSTR)str << "\r\n";
    }
    }
    }
    }
    catch(...)
    {
    cout << "catch...";
    } return nRetCode;
    }
      

  7.   

    要是用perl的正则表达式判断不是很难的 !