CURL Browser Emulator with PHP

谁都会走 提交于 2020-01-03 04:01:26

问题


I'm looking if someone has done this already. What I want basically is to make a browser out of CURL. By default, when CURL Data is fetched and outputted - it displays nicely, until you click on a link or fill a form (from browser, not php). Is it possible to make CURL Emulate a browser ? So the end result would be CURL opening a Login URL (and displaying it) and then when Login form is submitted (from browser), it automatically logs in (via CURL), when a link in admin panel is clicked (from browser) it it parsed with CURL and the correct URL is again crawled with CURL ?

Or can maybe someone give me a heads up how services like hidemyass.com are working ? (not looking to create a proxy server or something like that)


回答1:


Is it possible to make CURL Emulate a browser ?

In the context of your question, the answer is no. CURL in your case is taking the role to perform the HTTP requests (the network or protocol layer), but you're concerned about output. CURL is independent to output, it just performs the request and fetches the response data.

When you display the response data, it will be as returned, so you must take care of the output like changing all URLs within the document to a new URL that is pointing again to your service.

For that you need a HTML parser and a library to deal with URL resolvement. Such components already exist (e.g. DomDocument, Net_URL2).



来源:https://stackoverflow.com/questions/7120683/curl-browser-emulator-with-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!