简体   繁体   English

从实时数据提要php中读取

[英]Read from live data feed php

I am using something called DAP ( https://github.com/rapid7/dap ) which helps deal with large file handling and outputs an ever growing list of data. 我正在使用一种称为DAP( https://github.com/rapid7/dap )的东西,它可以帮助处理大型文件并输出不断增长的数据列表。

For example: 例如:

curl -s https://scans.io/data/rapid7/sonar.http/20141209-http.gz | zcat | head -n 10 | dap json + select vhost + lines

This code correctly works and it will output 10 lines of IP addresses. 该代码可以正常工作,它将输出10行IP地址。

My question is how can I read this data from PHP - in effect where a data feed is continuous/live (it will end at some point) how can I process each line I'm given? 我的问题是如何从PHP读取此数据-实际上是数据馈送是连续/实时的(它将在某个时刻结束),如何处理给出的每一行?

I've tried piping to it but I don't get passed the output. 我试过管道,但没有通过输出。 I don't want to use exec because the data is constantly growing. 我不想使用exec,因为数据在不断增长。 I think it could be a stream but not sure that is the case. 我认为这可能是一条小溪,但不确定情况是否如此。

For anyone else that finds themselves in the same situation - here is the answer that works for me (can be run directly from the command line also): 对于发现自己处在相同情况下的任何人-这是对我有用的答案(也可以直接从命令行运行):

curl -s 'https://scans.io/data/rapid7/sonar.http/20141209-http.gz' | zcat | head -n 1000 | dap json + select vhost + lines | while read line ; do php /your_script/path/file.php $line ; done

Then pull out $argv[1] and the data is all yours. 然后取出$ argv [1],数据就全在您了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM