Java login principle based on Jsoup jar package for web crawler

Source: Internet
Author: User

Straight to the subject:

This article is for people who have jsoup to grasp the basis of the person to see ...

Today's small series to everyone to write an article for the Jsoup to enter a verification code for one of the solutions. The great God on the Detour, hehe ~

The basis of any grab packet is based on the HTTP protocol to do this packet capture behavior, then, when we encounter the verification code, what to do? Don't worry, keep looking.

What to do if you encounter a verification code:

For example we want to visit www.xxxxx.com this site requires you to enter a verification code, the steps are as follows:

1) First we apart, first visit www.xxxxx.com This website, what is the purpose?

A. Access to cookies

B. Get ready for our next verification code

C. Take advantage of Jsoup's first access to www.xxxxx.com cookies for our second visit.

2) What do we do for a second visit after we have finished our first visit?

A. Use Jsoup with a cookie to access www.xxxxx.com/img/verifyCode.gif this address to obtain a verification code

B. Store the acquired verification code locally (generally obtained in binary form)

C. Using Jsoup with cookies to Www.xxxxx.com/img/verifyCode.gif to obtain the verification code can we log in?

3) Third visit we bring in Account + password + verification code to login it's important not to forget the cookie.

A. Third visit www.xxxx.com/login.html?username=haojieli&password=123456&verifyCode=1234 followed by the value of the cookie

Analytical:

The point is that the cookie is the primary condition of the session, and the cookie is the equivalent of the call, the phone you entered is to be able to speak to the other person's phone number, so the subsequent access to the verification code and login must be with a cookie, which is the standard you will recognize when you visit the server.

Conversely: When you go to the server to obtain the verification code when the cookie is 123456789, and you log on the time of the cookie is 888888888, you call is not the same phone, answer the phone is certainly not the same person, so when visiting the attention to keep the cookie consistent!

This is the end of the blog, thank you for watching, I hope to help readers, if you have any comments and suggestions please comment on the message ...

====== wish you a happy life ======

Java login principle based on Jsoup jar package for web crawler

Related Article

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.