我在 PHP 中有一个脚本,该脚本使用 multi curl 连接到执行以下操作的网站:
- login to the site
- get a page
- verify the page content
- if the content is what I need I do 5.
- post some data to the site.
- log out.
我的脚本可以同时登录 <20 个站点,但速度不是太快,而且会占用大量服务器资源。
我可以将脚本转换为 Python 或其他语言以使其更快吗? 我不知道是否可以使用 firefox 或其他浏览器来发送命令并获取内容? 示例:
system("firefox http://stackoverflow.com/users/login");
system("firefox post-data:username=stack&password=some");
system("firefox getcontent > mypage.html");
这可能看起来是一个疯狂的解决方案 :) 但我需要提高 PHP 脚本的性能。
非常感谢, 阿德里安
请您参考如下方法:
我认为它与语言的关系不大,而与等待 HTTP 请求的关系更大。听起来您没有做任何会导致 PHP 成为瓶颈的事情。
我将从测试 HTTP 请求所花费的时间开始。我敢打赌这就是您的瓶颈所在。
