抓取网页数据、下载网络图片
来源:互联网 发布:贵阳大数据会议 编辑:程序博客网 时间:2024/06/09 23:42
通过jsoup抓取网页数数据<pre name="code" class="java">Document doc = Jsoup.connect("http://www.chinau.cc/cata/detail?cid=2060").timeout(5000000).get();Elements url = doc.select(".content .dleft .x_img").select("tbody td img");//就想像jquery那样去找到对应的元素(Element)或者多个元素(Elements)去做相应的操作即可//attr(..),text(),html()对应这jquery的方法基本都有
<pre code_snippet_id="402777" snippet_file_name="blog_20140623_7_6691604" name="code" class="java">
下载网络图片/** * 下载网络图片 * @param url 网络路径 * @param path 本地保存路径 * @param fileName 保存文件名 * @throws IOException * */public static void downUrl(String urlStr,String path,String fileName) throws IOException{URL url = new URL(urlStr); //构建URLURLConnection con = url.openConnection(); //打开连接con.setConnectTimeout(5*10*1000);//设置超时连接//读入网络图片流InputStream inStream = con.getInputStream();File file = new File(path);//保存路径if (!file.exists()) {file.mkdirs();}//图片输出流OutputStream outStream = new FileOutputStream(file+"\\"+fileName);byte[] b = new byte[1024];int len = 0 ;while ((len = inStream.read(b)) != -1) {outStream.write(b, 0, len);}//关闭数据流outStream.close();inStream.close();}
0 0
- 抓取网页数据、下载网络图片
- 抓取网页信息,下载网络图片到本地
- python网络爬虫,抓取网页图片
- 关于java抓取网页数据与图片
- java中用jsoup抓取网页源码,并批量下载图片
- JAVA抓取网页图片并下载到本地
- 爬虫抓取网页图片
- 从网页抓取图片
- python抓取网页图片
- python抓取网页图片
- php抓取网页图片
- java 抓取网页图片
- 爬虫抓取网页图片
- 网页图片抓取
- Python抓取网页图片
- Python3抓取网页图片
- python抓取网页图片
- Python抓取网页图片
- 解决在浏览器中打开java文件jnlp报错“该文件没有程序与之关联来执行该操作...”
- Android开发执行adb 命令行命令
- IE双击无法打开,进程中也无,通过管理员账户也无法打开
- swift之初见
- ASM基本操作
- 抓取网页数据、下载网络图片
- 堆与堆排序
- 笔记一下下
- python操作Excel读写--使用xlrd
- Orange'S代码用gdb+bochs调试的问题
- 重构
- Java问答:终极父类(2)—上篇
- 网站在不同的并发访问量级下Mysql的应用架构演变
- 100_leetcode_Flatten Binary Tree to LinkList