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.