Python3 under Scrapy Crawler (Volume Fifth: Using cookies to simulate Landing Crawl Personal Center page)

Source: Internet
Author: User

Before we climbed are those who do not need to login to be able to use the site but when we want to crawl themselves or other people's personal center need to do login, generally enter the login page there are two, one is a separate page landing, the other is the pop-up window, we first regardless of the verification code landing problem, now try a direct landing crawl:

Reptiles are simulated human behavior to request a webpage to read the data now we divide the process, from landing to acquiring:

Let's take a look at the process of our personal center:

Login interface, enter your account password, enter your personal center

1 Enter the landing page can be said that the first request at this time will produce the corresponding cookie value, because you only need to enter the page before you can enter the password and other behavior

Cookiejar:1 to open Cookie record

Now look at the callback function:

2 Enter the landing page after the input data behavior, in the form of a POST request, the data transmitted in the network to find the field, is generally number,username what the data as a post carry

Look at the results.

3 before the request is the landing page with a GET request, now need to do a step login process becomes a POST request, that is, the second step request, the same is done in the parse function

4 meta={' Cookiejar ': True} means using the licensed cookie to access pages that need to be logged in to view

5 Obtain the cookie after the request, respond to the cookie, and then proceed to get the personal center:

Look at the results:

Python3 under Scrapy Crawler (Volume Fifth: Using cookies to simulate Landing Crawl Personal Center page)

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.