#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <strings.h>
#include <string.h>
#include <sys/types.h>
#include <errno.h>
char *http[255] = {
"网址1",
"网址2",
"网址3"
};
int main(int argc, char **argv)
{
int i = 0, j = 0;
char buf[100];
while(http[i])
{ i++;
}
printf("i = %d\n", i); // 有2个网址
j = i;
bool:
while(i > 0) // i = 3.2.1.0
{ i--;
printf("http[%d] = %s\n", i, http[i]); // i = 1
bzero(buf, 100);
sprintf(buf, "curl %s", http[i]);
system(buf);
sleep(3);
}
sleep(60);
i = j; // 从新将网页个数填入 i
goto bool; // 再次循环访问各个网址
return 0;
}
Linux编程: 循环间隙访问多个网址
猜你喜欢
转载自blog.csdn.net/qq_38813056/article/details/85274297
今日推荐
周排行