mechanize for Java
mechanize is a stateful HTTP web services client with support for HTML, JSON, and XML services.
Today, the code is mostly functional with automated tests, but the documentation is sparse. We especially need some tutorials. See the forum and GitHub for more details.
Pingback: Announcing mechanize for java | Gist Labs
Hi, I use Mechanize with Perl and I’m looking for a similar library to use it in Android (Java) apps. Glad I found your project!
Many times I use in my scripts in Perl:
$mech->post (…);
Is there a possibility to do it with your library?
Thanks in advance!
Cheers,
mat
Hello Mat,
Thanks for commenting, and the feature request.
I’m sure we can expose post directly (and you are welcome to contribute a pull request on GitHub is you were inspired.)
Are you thinking something like:
agent.post(url, mapNameValueParams)
Cheers,
John
Hi John,
thanks for your answer.
Exactly. In Perl it’s inherited from LWP::UserAgent. There we can do for example:
my $response = $browser->post($url,
[ 'value1'=>"2",
'value2'=>"0",
## etc.etc.etc....
], @ns_headers);
Would be great to see it in your Java implementation.
Hello mat,
I’ve create https://github.com/GistLabs/mechanize/issues/4 to track this request.
I’m not sure how nicely we’ll get the syntax in Java, but this is definitely a good idea.
Cheers,
John
Hello mat,
You can check out the 0.9.0-SNAPSHOT with the new api methods to support this. Heres the new code: https://github.com/GistLabs/mechanize/blob/master/src/main/java/com/gistlabs/mechanize/MechanizeAgent.java
Cheers, John
Dear,
I’m trying to use mechanize, but I’ve problem with dependencies. NetBeans cannot find the following symbols in MechanizeAgent.java
import org.apache.http.Header;
import org.apache.http.HttpException;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.BasicHttpContext;
In Debug.java:
import org.apache.http.Header;
import org.apache.http.HttpMessage;
In CacheEntry.java
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpMessage;
import org.apache.http.HttpResponse;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.message.BasicHttpResponse;
and others….
NetBeans add the following libraries like dependencies:
ant-1.8.1
commons-logging-1.0.4
css-selector-1.0.4
httpclient-4.0.1
httpmime-4.0.1
json-20090211
jsoup-1.7.1
ant-launcher-1.8.1
Can you help me to solve the problem?
Thanks
Errata correge.
All works fine. I run “Clean and Build” and NetBeans downloads the missing dependencies.
Sorry.
Is there a way to parse the response in addition to tag links? E.g. If I want to have every lines between and
I find the solution. Thanks.