我想编一个程序,不停访问一个url,其实就是增加页面的访问量,用什么控件?(100分)

  • 主题发起人 主题发起人 flmn
  • 开始时间 开始时间
F

flmn

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样实现?
 
呵呵,我在CSDN,CB版有个访问的,用API写的,改改就行了。怎么跑这来了?
[:D][:D][:D]
 
呵呵
你怎知我跑过来的?

呵呵
因为现在要写,最好马上能用

这里人多
 
indy: idhttp
fastnet: nmhttp
 
http://expert.csdn.net/Expert/topic/1249/1249195.xml?temp=.1246454
你要CB的还是D的?

我顺路来这逛,呵呵。
 
当然是cb

你见过我在csdn的id?
 
http://expert.csdn.net/Expert/topic/1239/1239544.xml?temp=.7300531
打错,这个才是
[:D][:D][:D][:D]
 
呵呵,你在水园打KISS?还记得?
 
想起来了,那天后半夜...
 
呵呵,没打成:(
 
[:D][:D][:D][:D][:D][:D][:D][:D][:D]
 
说正经的

我就给程序输入一个url

然后它替我不停访问就行了,就是要增加一个页面的访问量
 
url就是这个:http://211.71.4.52/community/bbs/showthread.php?threadid=1276

如果全世界的程序员联系起来,我也就不用写程序了:)
 
簡單一點的用WebBrowser1加一個Time
WebBrowser1.Navigate('url');

 
static const String CRLF = "/r/n";

int GetResponse(const String data, const String SContent)
{
int Result = -1;
TStrings *List = new TStringList;
List->Text = data.LowerCase();
for(int i = 0; i < List->Count; ++i)
{
int start = List->Strings.Pos(SContent);
if(start)
{
String s = List->Strings.SubString(SContent.Length() + 1, MaxInt);
int j = LastDelimiter(" ", s);
while (j)
{
s = s.SubString(1, j - 1);
j = LastDelimiter(" ", s);
}
Result = s.ToInt();
break;
}
}
delete List;
return Result;
}

int GetHTTPServer(const String data)
{
static const String SContent = "http/1.1 ";
return GetResponse(data, SContent);
}

int GetContentSize(const String data)
{
static const String SContent = "content-length: ";
return GetResponse(data, SContent);
}

bool WaitForData(int s, int Timeout)
{
TFDSet FDSet;
TTimeVal TimeVal;
TimeVal.tv_sec = Timeout;
TimeVal.tv_usec = 0;
FD_ZERO(&FDSet);
FD_SET(s, &FDSet);
return(select(0, &FDSet, NULL, NULL, &TimeVal) > 0);
}

String ReceiveLine(int s)
{
char C;
int RetLen;
String Result = "";
while(1)
{
RetLen = recv(s, &C, 1, 0);
if(0 == RetLen || SOCKET_ERROR == RetLen) throw ESocketError("Socket read error");
Result += C;
if(Result.Pos(CRLF) > 0) break;
}
return Result;
}
String SendCommand(int s, String Command)
{
String Data = "", Result = "";
send(s, Command.c_str(), Command.Length(), 0);
while(WaitForData(s, 5))
{
Data = ReceiveLine(s);
if(CRLF == Data)
break;
else
Result += Data;
}
return Result;
}

static const String SUserAgent =
"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";
static const String SRequestFileHead =
"HEAD %s HTTP/1.1" + CRLF +
"Pragma: no-cache" + CRLF +
"Cache-Control: no-cache" + CRLF +
SUserAgent + CRLF +
"Host: %s" + CRLF + CRLF;
static const String SRequestFileContent =
"GET %s HTTP/1.1" + CRLF +
"Accept: */*" + CRLF +
SUserAgent + CRLF +
"RANGE: bytes=%d-" + CRLF +
"Host: %s" + CRLF + CRLF;

void ExtractHTTPHost(const String AURL, String &AHost, String &AFileName)
{
static const String HTTPHEAD = "http://";
int Index, HTTPLen = HTTPHEAD.Length();
AHost = AURL;
Index = AURL.Pos(HTTPHEAD);
if(Index)
AHost = AHost.SubString(Index + HTTPLen, MaxInt);
Index = AHost.Pos("/");
while(Index)
{
AHost = AHost.SubString(1, Index - 1);
Index = AHost.Pos("/");
}
Index = AURL.Pos(AHost) + AHost.Length();
AFileName = AURL.SubString(Index, MaxInt);
}
in_addr LookupName(const String HostName)
{
in_addr Result;
hostent *p = gethostbyname(HostName.c_str());
memset(&Result, 0, sizeof(Result));
if (p)
Move(p->h_addr_list[0], &Result, p->h_length);
return Result;
}

int GetHttpHead(String URLFile)
{
int Result = SOCKET_ERROR;
WSAData data;
if (WSAStartup(MAKEWORD(2, 2), &data) != 0)
return Result;
try
{
int s = socket(PF_INET, SOCK_STREAM, IPPROTO_IP);
if (INVALID_SOCKET == s)
throw ESocketError("create socket error");
try
{
AnsiString Host, FileName;
ExtractHTTPHost(URLFile, Host, FileName);

//如果只是个主机,那访问“/”
if (FileName == "") FileName = "/";

sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_addr = LookupName(Host);
addr.sin_port = htons(80);

int ret = connect(s, (sockaddr*)&addr, sizeof(addr));
if (SOCKET_ERROR == ret)
throw Exception("can't not connect");

String Command = Format(SRequestFileHead, ARRAYOFCONST((FileName, Host)));
String Data = SendCommand(s, Command);
Result = GetContentSize(Data);
}
__finally
{
closesocket(s);
}
}
__finally
{
WSACleanup();
}
return Result;
}

void __fastcall TForm1::Button2Click(TObject *Sender)
{
Caption = GetHttpHead("www.delphibbs.com");
}
 
你试试,如果可以了,你再用线程再包起来访问,[:D][:D][:D]
 
简单的东西。以前在腾讯bbs刷屏的时候就写了一个。呵呵。原理很简单,就是用WebBrowser不断地连接。
 
先用WebBrowser刷着,再慢慢研究copy_paste兄的代码,呵呵

谢谢啦
 
多人接受答案了。
 
后退
顶部