Java 在提取url 生成图片以及正则表达式

1,    https://blog.csdn.net/qq_24076135/article/details/78045034

2.     http://www.vogella.com/tutorials/JavaRegularExpressions/article.html#java-regex-examples

3.     https://www.w3cschool.cn/java/java-regex-character-classes.html

4.              提取文档内容:

package com.happySpider;

import java.io.*;
import java.net.*;


public class Main {

public static void main(String[] args) {
String urlTarget = "http://yun.52tencent.com:808/api/simple/nuomi/eat/meishi/2";
String happyOutputPath = "D:/happySpider/";
try {
URL happyUrl = new URL(urlTarget);//URl对象
URLConnection happyConnect = happyUrl.openConnection();//建立一个链接
InputStream happyStream = happyConnect.getInputStream();//创建为一个字节流

BufferedReader/*缓存 ¥ 类*/ happyBuffer = new BufferedReader(new InputStreamReader(happyStream,"UTF-8"));//字节流 编码形式 把字节流转换成字符流的缓冲区
PrintWriter happyOutputFile = new PrintWriter/*保存文件*/(new File(happyOutputPath+System.currentTimeMillis()/*转换成毫秒的时间,且永远不会重复*/+".doc"));
String happyLine;
while((happyLine = happyBuffer.readLine()/*逐行读取*/)!= null)
{

System.out.println(happyLine);
happyOutputFile.println(happyLine);
}
happyOutputFile.close();
happyBuffer.close();
}
catch(IOException ex){//定义了一个输入输出异常对象叫ex
ex.printStackTrace();
}
}
}

 

posted on 2018-05-05 10:15 leolaosao 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/leolaosao/p/8993847.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值