| 构造器和说明 |
|---|
WebAPIAction() |
| 限定符和类型 | 方法和说明 |
|---|---|
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 hClient,
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 webConv,
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格式
|
public com.meterware.httpunit.WebConversation getWebConversation()
APIActiongetWebConversation 在接口中 APIActionpublic com.meterware.httpunit.WebResponse getResponseByHost(String url, String postorget, com.meterware.httpunit.WebConversation wc)
APIActiongetResponseByHost 在接口中 APIActionpublic com.meterware.httpunit.WebResponse getResponseByPost(String url, String hostIP, int hostPort, HashMap<String,String> params, HashMap<String,String> headers)
APIActiongetResponseByPost 在接口中 APIActionpublic com.meterware.httpunit.WebResponse getResponseByHost(String url, String postorget, String hostIP, int hostPort)
APIActiongetResponseByHost 在接口中 APIActionpublic com.meterware.httpunit.WebResponse getResponseByHost(String url, String postorget, String hostIP, int hostPort, String hostName, String hostPassword)
APIActiongetResponseByHost 在接口中 APIActionpublic com.meterware.httpunit.WebResponse getResponseByPost(String url)
APIActiongetResponseByPost 在接口中 APIActionpublic com.meterware.httpunit.WebResponse getResponseByPost(String url, int connTimeOut, int readTimeout)
APIActiongetResponseByPost 在接口中 APIActionconnTimeOut - 最大连接的超时时间readTimeout - 读取数据的最大超时时间public com.meterware.httpunit.WebResponse getResponseByPost(String url, HashMap<String,String> parameters, HashMap<String,String> headers)
APIActiongetResponseByPost 在接口中 APIActionparameters - 接口请求的参数public com.meterware.httpunit.WebResponse getResponseByGet(String url)
APIActiongetResponseByGet 在接口中 APIActionpublic com.meterware.httpunit.WebResponse getResponseByGet(String url, int connTimeOut, int readTimeout)
APIActiongetResponseByGet 在接口中 APIActionconnTimeOut - 最大连接的超时时间readTimeout - 读取数据的最大超时时间public com.meterware.httpunit.WebResponse getResponseByGet(String url, HashMap<String,String> parameters, HashMap<String,String> headers)
APIActiongetResponseByGet 在接口中 APIActionparameters - 接口请求的参数public com.meterware.httpunit.WebResponse getResponseByHttpUnit(com.meterware.httpunit.WebConversation webConv,
String hostIP,
int hostPort,
String hostUser,
String hostPassword,
String postorget,
String url,
int connTimeOut,
int readTimeout,
HashMap<String,String> parameters,
HashMap<String,String> headers)
APIActiongetResponseByHttpUnit 在接口中 APIActionhostIP - 如果禁用host,则设此值为nullpostorget - post或get方式请求URL,不区分大小写parameters - URL参数headers - header设置public String getJSONValue(String jsonContent, String jsonPath)
getJSONValue 在接口中 APIActionjsonContent - json的内容jsonPath - json指定节点的路径public String getPageSourceByHttpClientWithGet(String url)
APIActiongetPageSourceByHttpClientWithGet 在接口中 APIActionpublic String getPageSourceByHttpClientWithPost(String url)
APIActiongetPageSourceByHttpClientWithPost 在接口中 APIActionpublic org.apache.http.HttpResponse getResponseByHttpClientWithGet(String url)
APIActiongetResponseByHttpClientWithGet 在接口中 APIActionpublic org.apache.http.HttpResponse getResponseByHttpClientWithPost(String url)
APIActiongetResponseByHttpClientWithPost 在接口中 APIActionpublic org.apache.http.HttpResponse getResponseByHttpClientWithPost(String url, String rawString)
APIActiongetResponseByHttpClientWithPost 在接口中 APIActionpublic org.apache.http.HttpResponse getResponseByHttpClientWithPost(String url, HashMap<String,String> headers, String rawString)
APIActiongetResponseByHttpClientWithPost 在接口中 APIActionpublic org.apache.http.HttpResponse getResponseByHttpClientWithPost(String url, File filePath)
APIActiongetResponseByHttpClientWithPost 在接口中 APIActionurl - url地址filePath - 文件路径public org.apache.http.HttpResponse getResponseByHttpClientWithPost(String url, HashMap<String,String> headers, File filePath)
APIActiongetResponseByHttpClientWithPost 在接口中 APIActionheaders - 需要添加的header值public org.apache.http.HttpResponse getResponseByHttpClientWithPost(String url, File filePath, org.apache.http.entity.ContentType contentType)
APIActiongetResponseByHttpClientWithPost 在接口中 APIActionfilePath - 文件路径contentType - 文件类型public org.apache.http.client.HttpClient getHttpClientWithProxy(String proxyHost, int proxyPort, String loginName, String loginPass)
APIActiongetHttpClientWithProxy 在接口中 APIActionproxyHost - 代理服务器IPproxyPort - 代理服务器端口loginName - 如果需要用户名,则需要提供用户名,否则留空loginPass - 如果需要密码,则需要提供密码,否则留空public org.apache.http.HttpResponse getResponseByHttpClient(org.apache.http.client.HttpClient hClient,
String url,
String method,
HashMap<String,String> headers)
APIActiongetResponseByHttpClient 在接口中 APIActionhClient - 带有代理的HTTPClientheaders - urlheader,如果没有则设为nullpublic org.jsoup.nodes.Document parseStringToDom(String html)
APIActionparseStringToDom 在接口中 APIActionpublic org.jsoup.nodes.Document parseStringToDom(URL url, int timeout)
APIActionparseStringToDom 在接口中 APIActiontimeout - 请求的超时时间public org.jsoup.nodes.Document parseFileToDom(File file)
APIActionparseFileToDom 在接口中 APIActionpublic org.jsoup.nodes.Document parseFileToDom(File file, String charset)
APIActionparseFileToDom 在接口中 APIActionpublic org.jsoup.nodes.Document parseBodyFragment(String bodyHtml)
APIActionparseBodyFragment 在接口中 APIActionpublic org.jsoup.Connection.Response getResponseByJsoupByGet(String url)
APIActiongetResponseByJsoupByGet 在接口中 APIActionpublic org.jsoup.Connection.Response getResponseByJsoupByPost(String url)
APIActiongetResponseByJsoupByPost 在接口中 APIActionpublic org.jsoup.Connection.Response getResponseByJsoup(String url, String method, HashMap<String,String> headers)
APIActiongetResponseByJsoup 在接口中 APIActionurl - 指定的URLmethod - 请求方式,为get或post,不区分大小写headers - 随请求一起发送的header数据public org.jsoup.Connection.Response getResponseByJsoup(String url, String method, HashMap<String,String> datas, HashMap<String,String> headers)
APIActiongetResponseByJsoup 在接口中 APIActionurl - 指定的URLmethod - 请求方式,为get或post,不区分大小写datas - 随请求一起发送的datas数据,某些场景下,可通过此方法直接操作参数。如登陆时的用户名和密码headers - 随请求一起发送的header数据public 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)
APIActiongetResponseByJsoup 在接口中 APIActionurl - 指定的URLmethod - 请求方式,为get或post,不区分大小写cookies - 随请求一起发送的cookies数据datas - 随请求一起发送的datas数据,某些场景下,可通过此方法直接操作参数。如登陆时的用户名和密码headers - 随请求一起发送的header数据isFollowRedirects - 如果url自动跳转,则是否follow这个跳转userAgent - 用户设置的代理public HttpsURLConnection getHttpsUrlResponse(String httpsUrl, String keyStoreFile, String pass)
APIAction String ls = IOUtils.toString(new InputStreamReader(httpsUrlConn.getInputStream()));或: List ls = IOUtils.readLines(new InputStreamReader(httpsUrlConn.getInputStream())); getHttpsUrlResponse 在接口中 APIActionhttpsUrl - https地址keyStoreFile - keyStoreFile文件地址pass - 验证密码public HttpsURLConnection getHttpsUrlResponse(String httpsUrl, File keyStoreFile, String pass)
APIAction String ls = IOUtils.toString(new InputStreamReader(httpsUrlConn.getInputStream()));或: List ls = IOUtils.readLines(new InputStreamReader(httpsUrlConn.getInputStream())); getHttpsUrlResponse 在接口中 APIActionhttpsUrl - https地址keyStoreFile - keyStore文件public HttpsURLConnection getHttpsUrlResponse(String httpsUrl, URI keyStoreFileUri, String pass)
APIAction String ls = IOUtils.toString(new InputStreamReader(httpsUrlConn.getInputStream()));或: List ls = IOUtils.readLines(new InputStreamReader(httpsUrlConn.getInputStream())); getHttpsUrlResponse 在接口中 APIActionhttpsUrl - https地址keyStoreFileUri - URI格式的keyStoreFile地址pass - 验证密码Copyright © 2016. All rights reserved.