How do you grab and analyze the page?

time:13-06-21 forum:PHP tools and code
  First, we must decide the URL address we will grab from http://hi.baidu.com/yama2008/item/40c6cf9d927bd2cbb7253118


[code]
.lt;?
$url =.Quot; http://www.domain.com.quot;
?.gt; [/code]

we grab the specified file and present it in an array through the function () function.


[code].lt;?
$url =.Quot; http://www.domain.com.quot;
$lines_array = file ($url); good, now there is already a file in the array. However, the text we want to analyze may not be all in one line. To solve this problem, we can simply transform the array $lines_array into a string. We can use the implode (x, y) function to implement it. If you want to use explode (set string variable array) later, set X to.Quot; |.quot; or.Quot;!.quot; or other similar separators may be better. But for our purposes, we'd better set X as a blank. Y is another necessary parameter because it is an array that you want to use implode ().


[code].lt;
$url =.Quot; http://www.domain.com.quot;
$lines_array = file. In this example, we want to get everything between.Lt; head.gt;.Lt; /head.gt. In order to analyze strings, we also need regular expressions.


[code].lt;
$url =.Quot; http://www.domain.com.quot;
$lines_array = file ($url); In the following format, the eregi () function is performed in the following format:

eregi (.Quot;.Lt; head.gt; (. *).Lt; /head.gt;.Quot; $lines_string, $head);

$lines_string is the string we are analyzing, and $head is an array that is stored after analysis.

finally, we can export data. Because only in.Lt; head.gt; and.Lt; /head.gt; there is an instance in which we can safely assume that there is only one element in the array, and that is what we want.


[code].lt;
$url =.Quot; http://www.domain.com.quot;
$lines_array = file ($url);

prev:Processing techniques for PHP passing th... next:PHP reads the MYSQL contents into two-di...
post comment
Notice



approved   If you find health food illegal, you...   The walls and towers of the Ji'nan m...   A rural girl's monologue: what's the...   How the deaf and dumb girls become t...   These old photos of Ji'nan, which ha...
rand   JS array usage description   PHP disables COOKIE to get SESSION   Analysis of PHP cookie and session   A brief description of the differenc...   PHP setcookie () function
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com