作者: pingc
发起请求
jnewbie有5种请求方式:get,post,hGet,pGet,cGet
| 请求 | 配置参数 | 配置请求头 | 配置cookie | 配置代理 | 加载动态数据 | 配置JS加载时间 | 备注 |
|---|---|---|---|---|---|---|---|
| get | yes | yes | yes | yes | no | no | 正常请求 |
| post | yes | yes | yes | yes | no | no | 正常请求 |
| hGet | yes | yes | yes | yes | yes | yes | JS兼容一般 |
| pGet | yes | no | no | yes | yes | yes | 需额外配置 |
| cGet | yes | no | no | yes | yes | yes | 需额外配置 |
get
//创建请求客户端JHtml jHtml = new JHtml();//发起get请求JPage jPage = jHtml.get("http://localhost");//打印返回内容System.out.println(jPage);
post
//创建请求客户端JHtml jHtml = new JHtml();//发起post请求JPage jPage = jHtml.post("http://localhost");//打印返回内容System.out.println(jPage);
hGet
//创建请求客户端JHtml jHtml = new JHtml();//发起hGet请求JPage jPage = jHtml.hGet("http://localhost");//打印返回内容System.out.println(jPage);
pGet
phantomjs下载地址:https://phantomjs.org/download.html
//配置phantomjs路径PhantomJSDriverManager.setDriverPath("C:\Users\Administrator\Desktop\phantomjs.exe");//创建请求客户端JHtml jHtml = new JHtml();//发起pGet请求JPage jPage = jHtml.pGet("http://localhost");//打印返回内容System.out.println(jPage);
cGet
chromedriver下载地址:http://npm.taobao.org/mirrors/chromedriver/
选择与Chrome浏览器对应的版本
//配置chromedriver路径ChromeDriverManager.setDriverPath("C:\Users\Administrator\Desktop\chromedriver.exe");//创建请求客户端JHtml jHtml = new JHtml();//发起cGet请求JPage jPage = jHtml.cGet("http://localhost");//打印返回内容System.out.println(jPage);
