kiddyuchina / beanbun Goto Github PK
View Code? Open in Web Editor NEWBeanbun 是用 PHP 编写的多进程网络爬虫框架,具有良好的开放性、高可扩展性,基于 Workerman。
License: MIT License
Beanbun 是用 PHP 编写的多进程网络爬虫框架,具有良好的开放性、高可扩展性,基于 Workerman。
License: MIT License
守护模式下,除了手工执行 php start.php stop 来停止之外,在代码里可以怎样可以正确地停止?
比如写个 timer 检查到 redis 队列为空之后,自动退出。
再整合一下好的数据解析清洗过滤功能就完美了...
在爬取百度搜索到的ur时,如果url有重定向,框架自动重定向了,但是url还是重定向之前的。
我尝试直接把GuzzleHttp\Client类的自动重定向配置设置为false,尝试后可以获取到即将重定向的页面,但是$beanbun->options中没有即将重定向的链接
看了源代码中去重使用的2种方法,一个是md5直接放redis set,这个数据量到百万千万后性能不行
另一个使用bloomfilter映射redis bitmap,这2者在爬取URL数量在千万级性能差距有多少?
PHP Warning: array_flip(): Can only flip STRING and INTEGER values! in /vendor/kiddyu/beanbun/src/Lib/Helper.php on line 44
有时间up一下,^_^
爬取获得的URL自动拼接了爬取的页面域名,缺乏检查判断
例子中都是get的,没有post的例程,不知道data数据在那里设定啊?能不能举一个post的例子呢。
$beanbun->seed = [
//'http://www.950d.com/',
[
'http://www.950d.com/list-2.html',
[
'method' => 'POST',
]
]
];
按例程中,这样设定,一是没有postdata数据,二是就算这样,也报错。crul error 3.
麻烦给个post的例子,谢谢
没有用过,有这么一个疑问,如果不能抓取JS渲染后的数据,那能不能配合phantomjs一起工作?
简洁实用啊
用的是框架还是自己搭的
redis queue can't use password ?
redis auth问题
连接Redis服务的时候,config中应该添加auth授权配置,并在构造函数中添加auth授权。
遇到某些 Seed 有时返回 500、或404、或超时,爬虫会一直重试,然后好像在爬一个空地址,而且也不进入afterDownloadPage。
1、网站故障无法避免,但爬虫应该要怎样正确处理这种情况?
2、在afterDownloadPage里除了 page 属性以外,能否获得网站返回的 http code 、Response Header Cookie 这些??
这个能抓2345小说,嘿嘿,写写正则就ok了,还有源码咋没用单元测试
[root@localhost www]# ls
composer.json composer.lock vendor
[root@localhost www]# vim start.php
[root@localhost www]# php start.php
PHP Fatal error: Uncaught Error: Class 'Beanbun\Beanbun' not found in /www/start.php:3
Stack trace:
#0 {main}
thrown in /www/start.php on line 3
[root@localhost www]#
这是刚刚用composer安装好,然后复制了start.php执行的结果
因为window平台不能使用守护模式,所以在window平台下使用只能把要爬的网页链接全部列出来吗
cURL error 28: Operation timed out after 60001 milliseconds with 49054 bytes received (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
请问是什么原因,怎么解决?
打开文档后页面一片空白
作为测试我配置了$beanbun->UrlFilter,给了一个seed让爬虫自己爬,在规则中大概能匹配7张页面,但是页面抓完之后一直没有执行stopWorker,而且任务管理器中的进程还在。
我尝试使用php start.php stop
,在任务管理器中看到爬虫进程已经结束了,但是还是还是没有执行stopWorker();
部分代码:
$bean->stopWorker = function($b){ $b->log('执行了一次stopWorker'); }
表现在:日志文件中并没有'执行了一次stopWorker'
use yii\console\Controller;
use Beanbun\Beanbun;
class DemoController extends Controller
{
public function actionBeanbun()
{
$beanbun = new Beanbun();
$beanbun->seed = [
'http://www.950d.com/',
'http://www.950d.com/list-1.html',
'http://www.950d.com/list-2.html',
];
$beanbun->afterDownloadPage = function ($beanbun) {
file_put_contents(__DIR__ . '/' . md5($beanbun->url), $beanbun->page);
};
$beanbun->start();
}
}
问题一
PHP Notice 'yii\base\ErrorException' with message 'Undefined property: Beanbun\Beanbun::$count'
in /xxx/vendor/kiddyu/beanbun/src/Beanbun.php:136
问题二
在Beanbun加上count属性后,发现依然不能工作
会一直提示
Usage: php yourfile.php {start|stop|restart|reload|status|connections} [-d]
http://beanbun.org/ 网址打不开了,没法学习了。
已经给设定$beanbun->max = 3;
但是爬虫会不停的爬,如果是长期爬取某一个网站,爬过的地址是不是存数据库比较准吧
大佬..有这类似的demo嘛大佬..
我爬取糗百的网址数据时,在守护模式下,日志中一直有cURL error 3: malformed这个错误,请问是哪里有问题啊?
爬虫框架我理解就是下载网页,对于下载下来的网页不不能进行分析,比如说提前网页标题,提取关键字,提取网页主内容摘要,缩略图这些是基本的,更高级别的还有很多了。
请问下作者你这个框架除了支持各种方式爬取之外,对爬下来的网页做进一步处理支持什么呢?或者有提供一种插件的形式可以让使用者自己来处理。
http://www.beanbun.org/#/
这个网址的文档,不知道为什么,打不开!~
翻了文档和源码,没有找到相关操作,能否对爬取过的url设置过期时间或者重复周期
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.