HTTP-POST同时请求 [英] HTTP-POST simultaneous requests

查看:97
本文介绍了HTTP-POST同时请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我想创建一个php scraper,它将从

获取一些信息,例如:同时有5个站点。我尝试了以下脚本:
http://www.phpied.com/simultaneuos-h...php-with-curl/

一切正常,但我想要的是同时(某些东西) />
多线程,这些5个网站将在

之后加载另一个,但是使用不同的套接字)刮刀。


另外我想尽快显示结果

刮。因此,当第一个http-post得到答案时,它将显示结果

并等待其余页面(当所有

抓取完成时不显示所有内容)。

任何想法我怎样才能实现它?谢谢!


问候,Mark

Hello,

I want to create a php scraper that will get some information from
e.g. 5 sites simultaneously. I tried the following script:
http://www.phpied.com/simultaneuos-h...php-with-curl/
Everything works fine, but what I want is simultaneuos (something to
multithread, when these 5 websites will be loaded not one after
another, but by using different sockets) scraper.

In addition I would like to display the results as soon as it will be
scraped. So when first http-post get answer, it will show the result
and wait for the rest of the pages (not display everything when all
scraping is done).
Any ideas how can I achieve it? Thanks!

regards, Mark

推荐答案

mark写道:
mark wrote:

您好,


我想创建一个php刮刀,它将从

获取一些信息,例如同时有5个站点。我尝试了以下脚本:
http://www.phpied.com/simultaneuos-h...php-with-curl/

一切正常,但我想要的是同时(某些东西) />
多线程,这些5个网站将在

之后加载另一个,但是使用不同的套接字)刮刀。


另外我想尽快显示结果

刮。因此,当第一个http-post得到答案时,它将显示结果

并等待其余页面(当所有

抓取完成时不显示所有内容)。

任何想法我怎样才能实现它?谢谢!


问候,Mark
Hello,

I want to create a php scraper that will get some information from
e.g. 5 sites simultaneously. I tried the following script:
http://www.phpied.com/simultaneuos-h...php-with-curl/
Everything works fine, but what I want is simultaneuos (something to
multithread, when these 5 websites will be loaded not one after
another, but by using different sockets) scraper.

In addition I would like to display the results as soon as it will be
scraped. So when first http-post get answer, it will show the result
and wait for the rest of the pages (not display everything when all
scraping is done).
Any ideas how can I achieve it? Thanks!

regards, Mark



对不起,PHP并没有做多线程。你可以做的最好的事情就是启动多个后台进程来完成工作然后通过数据库,共享内存等进行通信。


至于立即显示内容 - 再次,不保证

可能。你可以在PHP中刷新()缓冲区 - 但是这并不保证
保证数据将立即由网络服务器发送给客户端

,也不保证客户将在收到之前显示数据




听起来像java可能更合适。


-

==================

删除x来自我的电子邮件地址

Jerry Stuckle

JDS计算机培训公司
js ******* @ attglobal.net

==================

Sorry, PHP doesn''t do multithreading very well. Probably the best you
can do is start multiple background processes to do the work then
communicate via a database, shared memory, etc.

As for displaying the contents immediately - again, not guaranteed
possible. You can flush() the buffers in PHP - but that doesn''t
guarantee the data will be sent by the webserver to the client
immediately, nor does it guarantee the client will display the data
before it''s received.

Sounds like java might be a better fit.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


mark写道:
mark wrote:

另外我想尽快显示结果

刮了。因此,当第一个http-post得到答案时,它将显示结果

并等待其余页面(当所有

抓取完成时不显示所有内容)。

任何想法我怎样才能实现它?谢谢!
In addition I would like to display the results as soon as it will be
scraped. So when first http-post get answer, it will show the result
and wait for the rest of the pages (not display everything when all
scraping is done).
Any ideas how can I achieve it? Thanks!



要么:

- 在控制台中运行并使用fork()。

- 使用原始HTTP和一些socket_select()魔术。

- curl_multi_exec()。

- 依靠javascript,ajax技术,并启动网页浏览器5

查询你的网络服务器,每个人都在抓一个网站。

- 使用ignore_user_abort()和原始HTTP与套接字的混合来盲目地启动PHP线程
。这个是非常棘手的。


可能有更多的方法可以做到这一点,但除非你知道什么是关键的

部分,请远离并发(AKA多线程)编程。


此外,您希望IPC在出现时获得结果 - 让您的生活更轻松,b $ b更容易,你应该坚持使用curl_multi查询或依赖

javascript来单独获取结果,因为它们已准备就绪。

-

---- ------------------------------

Iv ?? n S ?? nchez Ortega -ivan- algarroba-sanchezortega-punto-es-

现在收听:Deep Forest - Music.Detected_(2002) - [4]电脑

机器(5: 12)(99.061996%)

Either:
- Run in console and use fork().
- Use raw HTTP and some socket_select() magic.
- curl_multi_exec().
- Rely on javascript, ajax techniques, and make a web browser launch 5
queries yo your web server, each of one scraping a site.
- Use ignore_user_abort() and a mix of raw HTTP with sockets to blindly
launch PHP threads. This one''s quite tricky to pull out.

There may be more ways to do this, but unless you know what a critical
section is, please stay away from concurrent (AKA multithread) programming.

Besides, you want IPC to get the results as they appear - to make your life
easier, you should stick with either curl_multi queries or rely on
javascript to individually fetch results as they are ready.
--
----------------------------------
Iv??n S??nchez Ortega -ivan-algarroba-sanchezortega-punto-es-

Now listening to: Deep Forest - Music.Detected_ (2002) - [4] Computer
Machine (5:12) (99.061996%)


您好,


于2008年4月10日05:09 PM标记如下:
Hello,

on 10/04/2008 05:09 PM mark said the following:

您好,


我想创建一个php scraper,它将从
$ b $获取一些信息b例如同时有5个站点。我尝试了以下脚本:
http://www.phpied.com/simultaneuos-h...php-with-curl/

一切正常,但我想要的是同时(某些东西) />
多线程,这些5个网站将在

之后加载另一个,但是使用不同的套接字)刮刀。


另外我想尽快显示结果

刮。因此,当第一个http-post得到答案时,它将显示结果

并等待其余页面(当所有

抓取完成时不显示所有内容)。

任何想法我怎样才能实现它?谢谢!
Hello,

I want to create a php scraper that will get some information from
e.g. 5 sites simultaneously. I tried the following script:
http://www.phpied.com/simultaneuos-h...php-with-curl/
Everything works fine, but what I want is simultaneuos (something to
multithread, when these 5 websites will be loaded not one after
another, but by using different sockets) scraper.

In addition I would like to display the results as soon as it will be
scraped. So when first http-post get answer, it will show the result
and wait for the rest of the pages (not display everything when all
scraping is done).
Any ideas how can I achieve it? Thanks!



这个类可以完全按照你的描述完成:

http://www.phpclasses.org/thread


这个其他类也使用单独的HTTP请求来运行多个

并行任务但这些是使用AJAX从浏览器端启动的

请求:

http://www.phpclasses.org/phpthreader

-


问候,

Manuel Lemos


查找和发布PHP工作
http://www.phpclasses.org/jobs/

PHP类 - 免费准备使用OOP用PHP编写的组件
http://www.phpclasses.org/

This class can do exactly what you describe:

http://www.phpclasses.org/thread

This other class also uses separate HTTP requests to run multiple
parallel tasks but these are started from the browser side using AJAX
requests:

http://www.phpclasses.org/phpthreader
--

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/


这篇关于HTTP-POST同时请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆