Home  >  Article  >  php教程  >  PHP抓取网页、解析HTML常用的方法总结,php抓取

PHP抓取网页、解析HTML常用的方法总结,php抓取

WBOY
WBOYOriginal
2016-06-13 08:59:28909browse

PHP抓取网页、解析HTML常用的方法总结,php抓取

概述

爬虫是我们在做程序时经常会遇到的一种功能。PHP有许多开源的爬虫工具,如snoopy,这些开源的爬虫工具,通常能帮我们完成大部分功能,但是在某种情况下,我们需要自己实现一个爬虫,本篇文章对PHP实现爬虫的方式做个总结。

PHP实现爬虫主要方法

1.file()函数
2.file_get_contents()函数
3.fopen()->fread()->fclose()方式
4.curl方式
5.fsockopen()函数,socket方式
6.使用开源工具,如:snoopy

PHP解析XML或HTML主要方式

1.正则表达式
2.PHP DOMDocument对象
3.插件,如:PHP Simple HTML DOM Parser

总结

这里对PHP实现爬虫的方式做个简单得总结,本篇设计到得内容还有很多,稍后会对PHP解析HTML和XML的方式做个总结。

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