C++利用BOOST和Wget提取百度图片实例
来源:互联网 发布:mac os 最新的版本号 编辑:程序博客网 时间:2024/05/22 10:34
本文转自.http://www.郭华.com/?p=235 转载请注明出处
作者: gh0716 / 2012年04月28日
C++利用BOOST和Wget提取百度图片实例。
只是作为一个简单的模型,没有其他目的。
由于临时写的,文件名和路径都很乱。抛砖引玉的作用。可以修改,做成其他批量工具。
转载、复制请注明出处http://www.xn--xkrx74l.com/?p=235
效果如下:
提取效果图:
源代码:
/* *作者:gh0716 *邮箱:gh0716@163.com *原理:boost分析网页 *网址:http://www.xn--xkrx74l.com/?p=235 *说明:需要配置boost和放置wget到exe目录,或者改写下载方式 *时间:2012年4月28日19:42:10 *目的:抛砖引玉*/#include<iostream>#include <boost/regex.hpp>#include <fstream>#include <UrlMon.h>#pragma comment(lib, "urlmon.lib")using namespace std; using namespace boost;int main() { regex reg("objURL\\\":\\\"([^\\\'\\\"\\s?]+\\.jpg)\\s*", boost::regex::perl|boost::regex::icase); smatch m; HRESULT hr =URLDownloadToFile(0,"http://image.baidu.com/i?ct=201326592&cl=2&nc=1&lm=-1&st=-1&tn=baiduimage&istype=2&fm=index&pv=&z=0&word=%C3%C0%CD%BC&s=0","index.html", 0,NULL);if(hr==S_OK){fstream file2("index.lst",ios::out|ios::app);fstream file("index.html",ios::in); string k; string s; while(!file.eof()) { file >> k; s += k; } string::const_iterator it = s.begin(); string::const_iterator end = s.end(); int n = 0; while (boost::regex_search(it,end,m,reg)) { n ++; cout << m[1] << endl; file2<<m[1]<<endl;it = m[1].second; } cout <<"共匹配到 "<< n <<"个链接"<< endl; file.close();file2.close();ShellExecute(NULL,"open","wget.exe" ,"-b -i index.lst -c",NULL,SW_HIDE);cout<<"OK"<<endl;} return 0; }
说明,需要配置boost和复制wget等部分文件过来。
需要源码的可以留下邮箱。
本文转自.http://www.郭华.com/?p=235 转载请注明出处。
- C++利用BOOST和Wget提取百度图片实例
- [boost] 利用boost.asio提取网页中的网址
- Boost - windows下编译boost和提取boost子集
- 仿百度图片实例
- 使用wget工具抓取网页和图片
- 利用Coco2dx提取plist中的图片
- 利用ffmpeg提取视频中的图片
- 入门android开发--实例--提取部分图片
- 用taglib提取mp3文件中的图片和一些其它信息的实例
- 利用线程换图片实例
- 使用HtmlParser 提取百度贴吧中的图片
- 百度编辑器内容之MIP图片替换,style提取
- 利用wget复制网站
- 利用wget下载
- 利用HtmlUnit抓取百度api商家图片
- 利用Python 实现下载百度图片
- 利用Jsoup扒取百度图片
- Caffe图片特征提取(Python/C++)
- poj 2430 Lazy Cows
- 分析3个数中最大的数
- 24岁到26岁 奔三的尴尬年纪,你要知道的事
- 多线程生产与消费
- 转行,学习JSP一个月总结
- C++利用BOOST和Wget提取百度图片实例
- Object类
- 黑马程序员--ADO基础
- 包装类
- windows下编译objective-c
- 异常的捕获及处理
- 继承CListView类的cs.style设置LVS_REPORT
- final关键字
- 路由决策原则