Ajax-php collection expert: Using curl to simulate login and capture data fails when the json call problem occurs. for help!

Source: Internet
Author: User
I recently learned to crawl php files and encountered a problem that had been plagued for a long time. I was crawling information on a page (Suppose. php), this page is just some basic html framework, and other key information is through ajax requests (B. php) back, the returned is json, and then in the page js will... I recently learned to crawl php files and encountered a problem that has been plagued for a long time,
I am capturing the information of a page (Suppose. php), this page is just some basic html framework, and other key information is through ajax requests (B. php). json is returned, and json is parsed and drawn to the page through page js. The key to the problem is that the ajax request information contains a mobile phone number that needs to be displayed after logon,
Method 1: Simulate logon and directly capture the page (a. php). ajax cannot be called across domains;
Method 2: capture json data using simulated login (B. php) to get the phone Information (api. php) that you want cannot be fully displayed,
Method 3: replace the page called by ajax (B. php) with the local address (api. php) and the page cannot be displayed.

Is it because the method I crawled is incorrect, the data cannot be captured at all, or the key parameters in my method are incorrect? Please kindly advise!

Supplement: I may not make it clear that the original website used ajax to request B. php to obtain json data,
If you directly access B. php can also directly obtain json data such as {"name": "zhangsan", "age": "17", "mobile": "135 *** 6789.
The problem is that mobile: 135 *** 6789 is not logged on, and. php will display 13533446789, but if B is enabled in the logon status. php is still not completely displayed (that is, only. php display all)
However, none of the above three methods can obtain the complete mobile phone number. So I want to ask if my crawling method is correct? Is there any experienced way to collect such data?
Note: I have successfully simulated logon and tried to set cookies, referer, and agent, but cannot display all the numbers.

Reply content:

I recently learned to crawl php files and encountered a problem that has been plagued for a long time,
I am capturing the information of a page (Suppose. php), this page is just some basic html framework, and other key information is through ajax requests (B. php). json is returned, and json is parsed and drawn to the page through page js. The key to the problem is that the ajax request information contains a mobile phone number that needs to be displayed after logon,
Method 1: Simulate logon and directly capture the page (a. php). ajax cannot be called across domains;
Method 2: capture json data using simulated login (B. php) to get the phone Information (api. php) that you want cannot be fully displayed,
Method 3: replace the page called by ajax (B. php) with the local address (api. php) and the page cannot be displayed.

Is it because the method I crawled is incorrect, the data cannot be captured at all, or the key parameters in my method are incorrect? Please kindly advise!

Supplement: I may not make it clear that the original website used ajax to request B. php to obtain json data,
If you directly access B. php can also directly obtain json data such as {"name": "zhangsan", "age": "17", "mobile": "135 *** 6789.
The problem is that mobile: 135 *** 6789 is not logged on, and. php will display 13533446789, but if B is enabled in the logon status. php is still not completely displayed (that is, only. php display all)
However, none of the above three methods can obtain the complete mobile phone number. So I want to ask if my crawling method is correct? Is there any experienced way to collect such data?
Note: I have successfully simulated logon and tried to set cookies, referer, and agent, but cannot display all the numbers.

The key to the problem is that the ajax request information contains a mobile phone number that needs to be fully displayed after logon.

It's not very clear what you mean. Do you mean to request the B. php page with the mobile phone number or return the json data in the B. php interface. Then you didn't know where your problem is.

You may need something like this.

Http://casperjs.org/

However, this type of stuff is not very efficient.

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.