java抓取有验证的页面内容
来源:互联网 发布:如何选购基金知乎 编辑:程序博客网 时间:2024/05/16 04:41
package zz.test.ssm.controller;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import javax.servlet.http.HttpServletRequest;import org.apache.commons.codec.binary.Base64;import org.apache.commons.httpclient.HttpClient;import org.apache.commons.httpclient.HttpException;import org.apache.commons.httpclient.HttpStatus;import org.apache.commons.httpclient.UsernamePasswordCredentials;import org.apache.commons.httpclient.auth.AuthScope;import org.apache.commons.httpclient.methods.GetMethod;import org.apache.commons.httpclient.methods.PostMethod;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.ResponseBody;@Controller@RequestMapping(value = "/mq")public class MqQueueController { @RequestMapping(value = "queue", method = RequestMethod.GET) @ResponseBody public String getMqQueue(HttpServletRequest request) throws HttpException, IOException { String response = ""; String queueName = request.getParameter("queue"); String username = "user"; String password = "pass"; String url = "http://192.168.50.2:1002/api/queues/%2Femsfeedback/"+queueName; HttpClient client = new HttpClient(); client.getState().setCredentials( new AuthScope("192.168.50.2", 1002), new UsernamePasswordCredentials(username, password)); GetMethod get = new GetMethod( url ); get.setDoAuthentication( true ); int status = client.executeMethod( get ); response = get.getResponseBodyAsString(); System.out.println(status+ "\n" + get.getResponseBodyAsString()); get.releaseConnection(); return response; }}
参考:
http://www.blogjava.net/jelver/articles/162339.html
http://www.cnblogs.com/loveyakamoz/archive/2011/07/21/2113247.html
0 0
- java抓取有验证的页面内容
- java抓取带验证码登陆后的页面
- java抓取网页内容--生成静态页面
- 用C#抓取AJAX页面的内容
- libcurl抓取base64编码的页面内容
- Jsoup抓取页面内容
- java-抓取指定URL网页的内容
- jsp简单抓取页面内容
- 如何抓取网站页面内容
- 自己写的一个正则表达式抓取页面内容
- Python网页抓取:获取页面中某段内容的xpath
- php curl抓取远程页面内容的代码分享
- 用selenium抓取需要拉动滑滚条的页面内容
- 获得有 域验证的网页内容
- JAVA 抓取网页内容
- 【JAVA】 抓取网页内容
- JAVA 抓取网页内容
- java 抓取网页内容
- OpenWrt 自学笔记(1)----源码下载
- Ugly Number的三道题
- Android的EditText在怎样获取焦点并弹出软键盘
- 关于concurrent的子包locks下reentrantReadwritelock的一点疑惑
- spring有办法在getBean的时候传入构造函数的参数吗?
- java抓取有验证的页面内容
- @Resource注解
- -bash: vim,ls: No such file or directory
- Android实现微信、QQ的程序前后台切换
- 第三课-遮罩
- JPA常用注解
- securecrt常用命令
- 自定义导航控制器的titleView实现多控制器的切换
- 移动