php爬虫 phpspider
<?php
/**
* Created by PhpStorm.
* User: brady
* Date: 2016/12/9
* Time: 17:32
*/
ini_set("memory_limit", "1024M");
require dirname(__FILE__).'/../core/init.php'; $url = "http://www.epooll.com/archives/806/";
$html = requests::get($url);
// 抽取文章标题
$selector = "//*[@id=\"content\"]/div[1]/div[1]/h1/a"; $title = selector::select($html, $selector);
// 检查是否抽取到标题
// 抽取文章作者
$selector = "//*[@id=\"content\"]/div[1]/div[1]/h6/span[1]";
$author = selector::select($html, $selector);
// 检查是否抽取到作者
// 去掉 作者:
$author = str_replace("作者:", "", $author);
//发布时间
$selector = "//*[@id=\"content\"]/div[1]/div[1]/h6/span[2]";
$time = selector::select($html, $selector);
$time = str_replace("发布时间:",'', $time);
$time = date("Y-m-d H:i:s",strtotime($time));
// 抽取文章内容
$selector = "//*[@id=\"content\"]/div[1]/div[2]";
$content = selector::select($html, $selector);
// 检查是否抽取到内容
$data = array(
'article_title' => $title,
'article_author' => $author,
'article_content' => $content,
);
// 查看数据是否正常
$res = db::insert("content", $data);
var_dump($res);
php爬虫 phpspider的更多相关文章
- 关于php网络爬虫phpspider。
		前几天,被老板拉去说要我去抓取大众点评某家店的数据,当然被我义正言辞的拒绝了,理由是我不会...但我的反抗并没有什么卵用,所以还是乖乖去查资料,因为我是从事php工作的,首先找的就是php的网络爬虫源 ... 
- 关于php网络爬虫phpspider
		前几天,被老板拉去说要我去抓取大众点评某家店的数据,当然被我义正言辞的拒绝了,理由是我不会...但我的反抗并没有什么卵用,所以还是乖乖去查资料,因为我是从事php工作的,首先找的就是php的网络爬虫源 ... 
- phpspider php爬虫框架
		其实我自身的不是经常写正则,而且不规则的html去写正则本身就是件很麻烦的事情,如果页面有些微变动和更新就得再次去维护正则表达式,其实是非常蛋疼的 我第一感觉就是去找一下爬虫的库,但是发现现在php爬 ... 
- phpspider爬虫框架的使用
		这几天使用PHP的爬虫框架爬取了一些数据,发现还是挺方便的,先上爬虫框架的文档 phpspider框架文档 使用方法其实在文档中写的很清楚而且在demo中也有使用示例,这里放下我自己的代码做个笔记 & ... 
- phpspider PHP 爬虫
		* 通过composer下载 composer require owner888/phpspider // composer.json { "require": { "o ... 
- [爬虫资源]各大爬虫资源大汇总,做我们自己的awesome系列
		大数据的流行一定程序导致的爬虫的流行,有些企业和公司本身不生产数据,那就只能从网上爬取数据,笔者关注相关的内容有一定的时间,也写过很多关于爬虫的系列,现在收集好的框架希望能为对爬虫有兴趣的人,或者 ... 
- php 爬虫框架
		发现两款不错的爬虫框架,极力推荐下: phpspider 一款优秀的PHP开发蜘蛛爬虫 官方下载地址:https://github.com/owner888/phpspider 官方开发手册:http ... 
- 利用phpspider爬取网站数据
		本文实例原址:PHPspider爬虫10分钟快速教程 在我们的工作中可能会涉及到要到其它网站去进行数据爬取的情况,我们这里使用phpspider这个插件来进行功能实现. 1.首先,我们需要php环境, ... 
- php爬虫最最最最简单教程
		php爬虫最最最最简单教程 一.总结 一句话总结:用的爬虫框架,却是用的自己的例子(因为网站结构的变化,作者的例子不一定好用) 爬虫框架 自己例子 1.发现自己的运行效果和作者的不一样怎么办? 耐下性 ... 
随机推荐
- 数据结构——动态链表(C++)
			定义一个节点: [cpp] view plain copy print? #include <iostream> using namespace std; typedef int T; ... 
- springMvc发布restFull风格的URL
			package zpark.controller; import org.springframework.stereotype.Controller; import org.springframewo ... 
- Maven的内置变量
			Maven内置变量说明: ${basedir} 项目根目录(即pom.xml文件所在目录) ${project.build.directory} 构建目录,缺省为target目录 ${project. ... 
- JNI系列——C文件中使用logcat
			1.在Android.mk文件中添加:LOCAL_LDLIBS += -llog 注:加载的这个库在NDK对应平台目录下的lib目录中. 2.在C文件中添加如下内容: #include <and ... 
- 二叉树的建立与递归遍历C语言版
			</pre><pre name="code" class="cpp">#include <stdio.h> #include ... 
- linux 远程桌面连接
			我们知道在windows下面我们可以用远程桌面连接来控制其它电脑, 但linux 远程桌面连接?不过在说怎样连接之前还是要先明确一个概念,为什么我标题没有用linux中的远程桌面连接呢, 这是因为Li ... 
- Shiro 学习笔记(二)——shiro身份验证
			身份验证: 在应用中证明他就是他本人.一般上用身份证.用户/密码 来证明. 在shiro中,用户需要提供principals (身份)和credentials(证明)给shiro,从而应用能验证用户身 ... 
- bzoj1503
			treap改了好长时间,erase写错了... #include<iostream> #include<cstdio> #include<cstdlib> usin ... 
- yum命令安装mysql
			linux下使用yum安装mysql,以及启动.登录和远程访问. 1.安装 查看有没有安装过: yum list installed mysql* rpm -qa | grep mysql* 查看有没 ... 
- perl push an array to hash
			#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @array=qw /fm1 fm2 fm3 fm4 fm5 fm6/; ... 
