Get_meta_tags (), CURL, and user-agent information in php

Source: Internet
Author: User
The following is a brief introduction to the get_meta_tags (), CURL, and user-agent information comparison in php. if you are interested in this article, please refer. The get_meta_tags () function is used to capture the web page... the following is a brief introduction to the get_meta_tags (), CURL, and user-agent information comparison in php. if you are interested in this article, please refer.

The get_meta_tags () function is used to capture webpages. In the form of tags, and load A one-dimensional array, name is the element subscript, content is the element value, the tag in the above example can get the array: array ('a' => '1 ', 'B' => '2 '). Others The tag is not processed, and this function only processesTag deadline, followed And will not continue to process, howeverPrevious It will still be processed.

The user-agent is part of the invisible header information submitted by the browser when requesting a webpage from the server. The header information is an array containing multiple information, such as the local cache directory and cookies. the user-agent is a browser-type declaration, such as IE, Chrome, and FF.

Capture a webpage today When the tag is used, it always gets a null value, but it is normal to directly view the source code of the web page, so it is suspected that the server has set the output according to the header information. First, use get_meta_tags () to capture a local file. then, the local file writes the obtained header information to the file. The result is as follows (replace with/for ease of viewing ):

  '192.168.30.205',    'PATH' => 'C:/Program Files/Common Files/NetSarang;C:/Program Files/NVIDIA Corporation/PhysX/Common;C:/Program Files/Common Files/Microsoft Shared/Windows Live;C:/Program Files/Intel/iCLS Client/;C:/Windows/system32;C:/Windows;C:/Windows/System32/Wbem;C:/Windows/System32/WindowsPowerShell/v1.0/;C:/Program Files/Intel/Intel(R) Management Engine Components/DAL;C:/Program Files/Intel/Intel(R) Management Engine Components/IPT;C:/Program Files/Intel/OpenCL SDK/2.0/bin/x86;C:/Program Files/Common Files/Thunder Network/KanKan/Codecs;C:/Program Files/QuickTime Alternative/QTSystem;C:/Program Files/Windows Live/Shared;C:/Program Files/QuickTime Alternative/QTSystem/; %JAVA_HOME%/bin;%JAVA_HOME%/jre/bin;',    'SystemRoot' => 'C:/Windows',    'COMSPEC' => 'C:/Windows/system32/cmd.exe',    'PATHEXT' => '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',    'WINDIR' => 'C:/Windows',    'SERVER_SIGNATURE' => '',    'SERVER_SOFTWARE' => 'Apache/2.2.11 (Win32) PHP/5.2.8',    'SERVER_NAME' => '192.168.30.205',    'SERVER_ADDR' => '192.168.30.205',    'SERVER_PORT' => '80',    'REMOTE_ADDR' => '192.168.30.205',    'DOCUMENT_ROOT' => 'E:/wamp/www',    'SERVER_ADMIN' => 'admin@admin.com',    'SCRIPT_FILENAME' => 'E:/wamp/www/user-agent.php',    'REMOTE_PORT' => '59479',    'GATEWAY_INTERFACE' => 'CGI/1.1',    'SERVER_PROTOCOL' => 'HTTP/1.0',    'REQUEST_METHOD' => 'GET',    'QUERY_STRING' => '',    'REQUEST_URI' => '/user-agent.php',    'SCRIPT_NAME' => '/user-agent.php',    'PHP_SELF' => '/user-agent.php',    'REQUEST_TIME' => 1400747529,)?>

Sure enough, there is no HTTP_USER_AGENT element in the array. apache does not have UA when sending a request to another server. After checking the information, the get_meta_tags () function does not have the capability to forge UA, so you can only use other solutions.

Later, I used CURL to obtain the webpage, but it was a little troublesome to use. I first forged the UA and then analyzed it using regular expressions.

Forgery:

 


Article URL:

Reprint ^ at will, but please attach the tutorial address.

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.