Have a strong curl, forget the httpclient!

Source: Internet
Author: User

This period of time want to do a Web Capture program, because a website uses anti-collection method, my httpclient always after login can't get to I want the past link. After countless traces found that the original people to return is a JavaScript page, and contains the frameset, during the nesting of a lot of frame. Because HttpClient's getresonsebody can only get the server side and cannot further parse and execute it. During the time to try to further the return of the JS Code simulation browser execution, but, suddenly think of PHP's Curl module is very powerful, it can be directly taken back. So just wondering if it would be easy to try curl?

Installing Curl

Java code
    1. Yum Install Curl Curl-devle



Download Java Bindings for Libcurl
http://curl.haxx.se/libcurl/java/

Configuring and Compiling Java-libcurl

Java code
    1. Gunzip curl-java-0.2. 2.tar.gz
    2. Tar xvf curl-java-0.2. 2.tar
    3. CD curl-java-0.2. 2
    4. Make



Note that the corresponding Javacurl library files are generated under Linux and some Java class source files that need to be used. However, note that the paths in makefile are configured in the directory you installed when you are translating.

Under Windows to compile into DLL files. In the eclipse environment, place the DLL file in windows/system32 or rewrite the header file according to your directory standard, and then perform the compilation. Otherwise, the Java.lang.UnsatisfiedLinkError error will be given.

For this error, we can see the powerful Jer discussion, post in:
http://www.iteye.com/topic/58461?page=2

Because, in the source file in Libcurl-java, there are

Java code
    1. try {
    2. //Loading up the shared JNI
    3. System.loadlibrary ("Javacurl");
    4. } catch (Exception e) {
    5. E.printstacktrace ();
    6. }



The packages that have been compiled in the relevant Windows environment are:
http://www.gknw.de/mirror/curl/curl_java/

Then, execute the Test.java file in the curl-java-0.2.2 package (you can change the URL inside to the stubborn website you want to log into)

Did you see that it was thoughtful of you to return what you wanted?

If you're using Ruby,python or Perl, just install their Libcurl binding module and take a dip in your world.

http://lovejuan1314.iteye.com/blog/290461

Have a strong curl, forget the httpclient!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.