我用perl写过,你在google用lwp找,会用c++的code
解决方案 »
- 郁闷了!写socket时,无法将结构体转换成char*发送
- sqlite下select * from table where的问题
- 想做个贪吃蛇的游戏,帮忙看下简单的绘图代码,为什么不显示,谢谢!
- CStatic 显示图片的刷新问题
- [高手解答]如何用程序实现创建共享目录(完全共享)以便局域网内计算机共享?
- liClock.HighPart: = (Byte1 & 8)! = 0;是什么意思?
- 请问怎么改listbox中字体的大小?
- VC爱好者的群2345411
- 学习vc++从哪里入门容易一些?
- 有高人能帮忙解决 一个问题么, 关于C++猜数字游戏(MFC)的一个程序
- 为什么不能添加类成员变量?
- 如何让函数ReadFile()在等待读取设备数据的时候返回?
1):FILE* 以TXT格式读入到内存。
2): strncmp(str1, "<a>")感觉不太好,不过能用
其实用 VB 方便些,就用 javascript + 自己写两个 组件 轻松搞定。不用自己去分析 什么 html 语法了。
可以运行的代码// 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;
}