Home  >  Article  >  Backend Development  >  Summary of common methods for crawling web pages and parsing HTML with PHP_PHP Tutorial

Summary of common methods for crawling web pages and parsing HTML with PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 09:47:35935browse

A summary of commonly used methods for PHP to crawl web pages and parse HTML

This article mainly introduces a summary of commonly used methods for PHP to crawl web pages and parse HTML. This article is only a summary of how to achieve this The methods for the two requirements are summarized. We only introduce the methods, not how to implement them. Friends in need can refer to it

Overview

Crawler is a function that we often encounter when making programs. PHP has many open source crawler tools, such as snoopy. These open source crawler tools can usually help us complete most of the functions, but in some cases, we need to implement a crawler ourselves. This article explains how to implement crawlers in PHP a summary.

Main methods to implement crawler in PHP

 1.file() function

 2.file_get_contents() function

 3.fopen()->fread()->fclose() method

 4.curl method

 5.fsockopen() function, socket mode

 6. Use open source tools, such as: snoopy

Main ways for PHP to parse XML or HTML

 1. Regular expression

 2.PHP DOMDocument object

3. Plug-ins, such as: PHP Simple HTML DOM Parser

Summary

Here is a brief summary of the way PHP implements crawlers. There is a lot more content in this article. Later, I will make a summary of the way PHP parses HTML and XML.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1025332.htmlTechArticleSummary of common methods for PHP to crawl web pages and parse HTML. This article mainly introduces PHP to crawl web pages and parse HTML. A summary of commonly used methods. This article only summarizes the methods that can achieve these two requirements...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn