温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

利用wget 和队列 模拟网络爬虫 (不带判重程序)

发布时间:2020-06-12 23:32:55 来源:网络 阅读:416 作者:wzdouban 栏目:编程语言
/*
利用wget  指令和队列 模拟实现网络爬虫
利用自己的站点wzsts.host3v.com测试了一下
有一点错误
文件运行后拿到index.html
对于连接仅仅可以拿到 html 和htm 结尾的 而.com的没有考虑(设计文件可能多)
一次测试后了解到如下问题:
1.文件应该有树形话还原网站目录
2.文本记录的连接应该分类化
项目运行需要 su 根权限进行 
因为mv命令
本项目仅仅适合在linux下运行
本项目给真真的linux 爬虫做铺垫
*/
#include<bits/stdc++.h>
using namespace std;
#include <stdlib.h>
#include <iostream>
#include <fstream>
string s("index.html");
queue<string>q;
 //略去一段
int main()
{
 //index.html
system("wget wzsts.host3v.com");

ofstream out("out.txt"); 
string mv("mv ");
string html(" html");
q.push(s);
  while(!q.empty())
   {
out<<q.front().c_str();   out<<"\n";  
if(strstr(q.front().c_str(),".html")||strstr(q.front().c_str(),".htm"))
  {
    fun(q.front().c_str()); 
    q.pop();
    string t("wget ");   t=t+s;  cout<<t.c_str()<<endl;
   system(t.c_str());
  }

string ss(q.front().c_str());
 ss=mv+ss.c_str()+html;     cout<<ss<<endl;
 system(ss.c_str());
   }

 out.close(); 
return 0;
}


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI