public interface APIAction
| 限定符和类型 | 方法和说明 |
|---|---|
org.apache.http.client.HttpClient |
getHttpClientWithProxy(String proxyHost,
int proxyPort,
String loginName,
String loginPass)
返回一个带有代理的HTTPClient,用于设置host
|
HttpsURLConnection |
getHttpsUrlResponse(String httpsUrl,
File keyStoreFile,
String pass)
请求https的URL,并获得响应内容,响应码,响应头,响应时间等。
|
HttpsURLConnection |
getHttpsUrlResponse(String httpsUrl,
String keyStoreFile,
String pass)
请求https的URL,并获得响应内容,响应码,响应头,响应时间等。
|
HttpsURLConnection |
getHttpsUrlResponse(String httpsUrl,
URI keyStoreFileUri,
String pass)
请求https的URL,并获得响应内容,响应码,响应头,响应时间等。
|
String |
getJSONValue(String jsonContent,
String jsonPath)
通过指定的jsonpath从json内容中取指定值。
|
String |
getPageSourceByHttpClientWithGet(String url)
使用Apache httpClient获取页面源代码。
|
String |
getPageSourceByHttpClientWithPost(String url)
使用Apache httpClient获取页面源代码。
|
com.meterware.httpunit.WebResponse |
getResponseByGet(String url)
get方式请求数据
|
com.meterware.httpunit.WebResponse |
getResponseByGet(String url,
HashMap<String,String> parameters,
HashMap<String,String> headers)
get请求
|
com.meterware.httpunit.WebResponse |
getResponseByGet(String url,
int connTimeOut,
int readTimeout)
通过get方式load数据
|
com.meterware.httpunit.WebResponse |
getResponseByHost(String url,
String postorget,
String hostIP,
int hostPort)
仅通过设置无需用户名和密码的代理来请求URL
|
com.meterware.httpunit.WebResponse |
getResponseByHost(String url,
String postorget,
String hostIP,
int hostPort,
String hostName,
String hostPassword)
支持host用户名和密码
|
com.meterware.httpunit.WebResponse |
getResponseByHost(String url,
String postorget,
com.meterware.httpunit.WebConversation wc)
本方法需要手动指定get或post方式,不区分大小,需要传入一个WebConversation对象
|
org.apache.http.HttpResponse |
getResponseByHttpClient(org.apache.http.client.HttpClient httpClient,
String url,
String method,
HashMap<String,String> headers)
使用代理抓取指定url的内容
|
org.apache.http.HttpResponse |
getResponseByHttpClientWithGet(String url)
使用Apache httpClient获取HttpResponse。
|
org.apache.http.HttpResponse |
getResponseByHttpClientWithPost(String url)
使用Apache httpClient获取HttpResponse。
|
org.apache.http.HttpResponse |
getResponseByHttpClientWithPost(String url,
File filePath)
此方法适用于需要post提交文件的需求
|
org.apache.http.HttpResponse |
getResponseByHttpClientWithPost(String url,
File filePath,
org.apache.http.entity.ContentType contentType)
此方法适用于需要post提交文件的需求
|
org.apache.http.HttpResponse |
getResponseByHttpClientWithPost(String url,
HashMap<String,String> headers,
File filePath)
此方法适用于需要post提交文件的需求
|
org.apache.http.HttpResponse |
getResponseByHttpClientWithPost(String url,
HashMap<String,String> headers,
String rawString)
此方法适用于部分字段需要post提交的需求,且可以添加header
|
org.apache.http.HttpResponse |
getResponseByHttpClientWithPost(String url,
String rawString)
此方法适用于部分字段需要post提交的需求
|
com.meterware.httpunit.WebResponse |
getResponseByHttpUnit(com.meterware.httpunit.WebConversation wc,
String hostIP,
int hostPort,
String hostUser,
String hostPassword,
String postorget,
String url,
int connTimeOut,
int readTimeout,
HashMap<String,String> parameters,
HashMap<String,String> headers)
使用HTTPUnit来抓取url内容
|
org.jsoup.Connection.Response |
getResponseByJsoup(String url,
String method,
HashMap<String,String> headers)
通过指定的请求方式method,使用Jsoup获得Response对象
|
org.jsoup.Connection.Response |
getResponseByJsoup(String url,
String method,
HashMap<String,String> datas,
HashMap<String,String> headers)
通过指定的请求方式method,使用Jsoup获得Response对象
|
org.jsoup.Connection.Response |
getResponseByJsoup(String url,
String method,
HashMap<String,String> cookies,
HashMap<String,String> datas,
HashMap<String,String> headers,
boolean isFollowRedirects,
String userAgent)
通过指定的请求方式method,使用Jsoup获得Response对象
|
org.jsoup.Connection.Response |
getResponseByJsoupByGet(String url)
通过Jsoup的Get方法获取Response对象,Response对象中包含响应内容,状态码等
|
org.jsoup.Connection.Response |
getResponseByJsoupByPost(String url)
通过Jsoup的Post方法获取Response对象,Response对象中包含响应内容,状态码等
|
com.meterware.httpunit.WebResponse |
getResponseByPost(String url)
通过post方式load数据
|
com.meterware.httpunit.WebResponse |
getResponseByPost(String url,
HashMap<String,String> parameters,
HashMap<String,String> headers)
post请求
|
com.meterware.httpunit.WebResponse |
getResponseByPost(String url,
int connTimeOut,
int readTimeout)
通过post方式load数据
|
com.meterware.httpunit.WebResponse |
getResponseByPost(String url,
String hostIP,
int hostPort,
HashMap<String,String> params,
HashMap<String,String> headers)
Post方式 + host请求URL
|
com.meterware.httpunit.WebConversation |
getWebConversation()
获取WebConversation对象,通过这个对象可以设置cookie,host,代理等
|
org.jsoup.nodes.Document |
parseBodyFragment(String bodyHtml)
如果传入的是一个完整的HTML内容,通过此方法只将body部分格式化成Document,而忽略title,header等
|
org.jsoup.nodes.Document |
parseFileToDom(File file)
将文件内容格式化成Document,默认编码是UTF-8
|
org.jsoup.nodes.Document |
parseFileToDom(File file,
String charset)
将指定的文件格式化成Document,charset为指定的编码格式
|
org.jsoup.nodes.Document |
parseStringToDom(String html)
将String字符串格式化成Document格式
|
org.jsoup.nodes.Document |
parseStringToDom(URL url,
int timeout)
通过get方式请求传入的url对象,并将结果格式化成Document格式
|
HttpsURLConnection getHttpsUrlResponse(String httpsUrl, String keyStoreFile, String pass)
String ls = IOUtils.toString(new InputStreamReader(httpsUrlConn.getInputStream()));或: List ls = IOUtils.readLines(new InputStreamReader(httpsUrlConn.getInputStream())); httpsUrl - https地址keyStoreFile - keyStoreFile文件地址pass - 验证密码HttpsURLConnection getHttpsUrlResponse(String httpsUrl, File keyStoreFile, String pass)
String ls = IOUtils.toString(new InputStreamReader(httpsUrlConn.getInputStream()));或: List ls = IOUtils.readLines(new InputStreamReader(httpsUrlConn.getInputStream())); httpsUrl - https地址keyStoreFile - keyStore文件pass - HttpsURLConnection getHttpsUrlResponse(String httpsUrl, URI keyStoreFileUri, String pass)
String ls = IOUtils.toString(new InputStreamReader(httpsUrlConn.getInputStream()));或: List ls = IOUtils.readLines(new InputStreamReader(httpsUrlConn.getInputStream())); httpsUrl - https地址keyStoreFileUri - URI格式的keyStoreFile地址pass - 验证密码com.meterware.httpunit.WebConversation getWebConversation()
com.meterware.httpunit.WebResponse getResponseByPost(String url, String hostIP, int hostPort, HashMap<String,String> params, HashMap<String,String> headers)
url - hostIP - hostPort - params - headers - com.meterware.httpunit.WebResponse getResponseByHost(String url, String postorget, com.meterware.httpunit.WebConversation wc)
url - postorget - wc - com.meterware.httpunit.WebResponse getResponseByHost(String url, String postorget, String hostIP, int hostPort)
url - postorget - hostIP - hostPort - com.meterware.httpunit.WebResponse getResponseByHost(String url, String postorget, String hostIP, int hostPort, String hostName, String hostPassword)
url - postorget - hostIP - hostPort - hostName - hostPassword - com.meterware.httpunit.WebResponse getResponseByPost(String url)
url - com.meterware.httpunit.WebResponse getResponseByPost(String url, int connTimeOut, int readTimeout)
url - connTimeOut - 最大连接的超时时间readTimeout - 读取数据的最大超时时间com.meterware.httpunit.WebResponse getResponseByPost(String url, HashMap<String,String> parameters, HashMap<String,String> headers)
url - parameters - 接口请求的参数headers - com.meterware.httpunit.WebResponse getResponseByGet(String url)
url - com.meterware.httpunit.WebResponse getResponseByGet(String url, int connTimeOut, int readTimeout)
url - connTimeOut - 最大连接的超时时间readTimeout - 读取数据的最大超时时间com.meterware.httpunit.WebResponse getResponseByGet(String url, HashMap<String,String> parameters, HashMap<String,String> headers)
url - parameters - 接口请求的参数headers - com.meterware.httpunit.WebResponse getResponseByHttpUnit(com.meterware.httpunit.WebConversation wc,
String hostIP,
int hostPort,
String hostUser,
String hostPassword,
String postorget,
String url,
int connTimeOut,
int readTimeout,
HashMap<String,String> parameters,
HashMap<String,String> headers)
wc - hostIP - 如果禁用host,则设此值为nullhostPort - hostUser - hostPassword - postorget - post或get方式请求URL,不区分大小写url - connTimeOut - readTimeout - parameters - URL参数headers - header设置String getJSONValue(String jsonContent, String jsonPath)
jsonContent - json的内容jsonPath - json指定节点的路径org.apache.http.client.HttpClient getHttpClientWithProxy(String proxyHost, int proxyPort, String loginName, String loginPass)
proxyHost - 代理服务器IPproxyPort - 代理服务器端口loginName - 如果需要用户名,则需要提供用户名,否则留空loginPass - 如果需要密码,则需要提供密码,否则留空org.apache.http.HttpResponse getResponseByHttpClient(org.apache.http.client.HttpClient httpClient,
String url,
String method,
HashMap<String,String> headers)
httpClient - 带有代理的HTTPClienturl - method - headers - urlheader,如果没有则设为nullString getPageSourceByHttpClientWithGet(String url)
url - String getPageSourceByHttpClientWithPost(String url)
url - org.apache.http.HttpResponse getResponseByHttpClientWithGet(String url)
url - org.apache.http.HttpResponse getResponseByHttpClientWithPost(String url)
url - org.apache.http.HttpResponse getResponseByHttpClientWithPost(String url, String rawString)
url - rawString - org.apache.http.HttpResponse getResponseByHttpClientWithPost(String url, HashMap<String,String> headers, String rawString)
url - headers - rawString - org.apache.http.HttpResponse getResponseByHttpClientWithPost(String url, File filePath)
url - url地址filePath - 文件路径org.apache.http.HttpResponse getResponseByHttpClientWithPost(String url, HashMap<String,String> headers, File filePath)
url - headers - 需要添加的header值filePath - org.apache.http.HttpResponse getResponseByHttpClientWithPost(String url, File filePath, org.apache.http.entity.ContentType contentType)
url - filePath - 文件路径contentType - 文件类型org.jsoup.nodes.Document parseStringToDom(String html)
html - org.jsoup.nodes.Document parseStringToDom(URL url, int timeout)
url - timeout - 请求的超时时间org.jsoup.nodes.Document parseFileToDom(File file)
file - org.jsoup.nodes.Document parseFileToDom(File file, String charset)
file - charset - org.jsoup.nodes.Document parseBodyFragment(String bodyHtml)
bodyHtml - org.jsoup.Connection.Response getResponseByJsoupByGet(String url)
url - org.jsoup.Connection.Response getResponseByJsoupByPost(String url)
url - org.jsoup.Connection.Response getResponseByJsoup(String url, String method, HashMap<String,String> headers)
url - 指定的URLmethod - 请求方式,为get或post,不区分大小写headers - 随请求一起发送的header数据org.jsoup.Connection.Response getResponseByJsoup(String url, String method, HashMap<String,String> datas, HashMap<String,String> headers)
url - 指定的URLmethod - 请求方式,为get或post,不区分大小写headers - 随请求一起发送的header数据datas - 随请求一起发送的datas数据,某些场景下,可通过此方法直接操作参数。如登陆时的用户名和密码org.jsoup.Connection.Response getResponseByJsoup(String url, String method, HashMap<String,String> cookies, HashMap<String,String> datas, HashMap<String,String> headers, boolean isFollowRedirects, String userAgent)
url - 指定的URLmethod - 请求方式,为get或post,不区分大小写headers - 随请求一起发送的header数据datas - 随请求一起发送的datas数据,某些场景下,可通过此方法直接操作参数。如登陆时的用户名和密码cookies - 随请求一起发送的cookies数据isFollowRedirects - 如果url自动跳转,则是否follow这个跳转userAgent - 用户设置的代理Copyright © 2016. All rights reserved.