mechanize

mechanize for java: stateful HTTP/HTML client

License

License

GroupId

GroupId

com.gistlabs
ArtifactId

ArtifactId

mechanize
Last Version

Last Version

2.0.0-RC1
Release Date

Release Date

Type

Type

jar
Description

Description

mechanize
mechanize for java: stateful HTTP/HTML client
Project URL

Project URL

http://gistlabs.com/software/mechanize
Project Organization

Project Organization

Gist Labs
Source Code Management

Source Code Management

https://github.com/GistLabs/mechanize

Download mechanize

How to add to project

<!-- https://jarcasting.com/artifacts/com.gistlabs/mechanize/ -->
<dependency>
    <groupId>com.gistlabs</groupId>
    <artifactId>mechanize</artifactId>
    <version>2.0.0-RC1</version>
</dependency>
// https://jarcasting.com/artifacts/com.gistlabs/mechanize/
implementation 'com.gistlabs:mechanize:2.0.0-RC1'
// https://jarcasting.com/artifacts/com.gistlabs/mechanize/
implementation ("com.gistlabs:mechanize:2.0.0-RC1")
'com.gistlabs:mechanize:jar:2.0.0-RC1'
<dependency org="com.gistlabs" name="mechanize" rev="2.0.0-RC1">
  <artifact name="mechanize" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.gistlabs', module='mechanize', version='2.0.0-RC1')
)
libraryDependencies += "com.gistlabs" % "mechanize" % "2.0.0-RC1"
[com.gistlabs/mechanize "2.0.0-RC1"]

Dependencies

compile (6)

Group / Artifact Type Version
org.jsoup : jsoup jar 1.7.1
org.json : json jar 20090211
se.fishtank : css-selectors jar 1.0.5
org.apache.httpcomponents : httpclient jar 4.0.1
org.apache.httpcomponents : httpmime jar 4.0.1
com.damnhandy : handy-uri-templates jar 2.0.1

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.mockito : mockito-core jar 1.9.5

Project Modules

There are no modules declared in this project.

mechanize for java

mechanize is a stateful HTTP web services client library (RESTful) with support for HTML, JSON, and XML services. Because mechanize is stateful and allow inspection of web resources, it naturally support GET-then-POST semantics and helps avoid hard-coding clients.

See the Mechanize Wiki for more details and opinions on how RESTful clients should behave.

====== Releases:

  • 1.x is the original port of mechanize to java. This will be maintained for bug fixes and possibly other enhancements.
  • 2.x is the modularized version to separate HTML, JSON, and XML into separate a la carte packages. Also the JSON linking dev will be here.

========

Here is a testcase showing mechanize at work with HTML:

	@Test public void testGooglePageSearchForm() {
		MechanizeAgent agent = new MechanizeAgent();
		Document page = agent.get("http://www.google.com");
		Form form = page.form("f");
		form.get("q").set("mechanize java");
		Resource response = form.submit();
		assertTrue(response.getTitle().startsWith("mechanize java"));
	}

Here is a testcase showing mechanize using a Google JSON web service:

	@Test
	public void testGoogleApi() throws JSONException {
		MechanizeAgent agent = new MechanizeAgent();
		JsonDocument json = agent.doRequest(googleUrl).add("shortUrl", shortUrl).add("projection", "FULL").get();

		assertEquals(longUrl, json.getRoot().find("longUrl").getValue());

		String value = json.getRoot().find("analytics month countries#US count").getValue();
		assertTrue(value, Integer.valueOf(value)>=1);
	}

=========

Include this library (or download) from the Maven repository: http://search.maven.org/#browse%7C687823805

com.gistlabs

Gist Labs

Versions

Version
2.0.0-RC1
1.0.0-RC1
0.13.1
0.11.2
0.11.0
0.10.0
0.9.2
0.9.1
0.9.0
0.8.0