I am using phpQuery to simulate a browser request. Codes are simple as follow:
require_once('phpQuery/phpQuery.php');
phpQuery::browserGet($url, 'success1');
function success1($browser) {
print $browser;
}
where URL is http://www.etk.cc/bmw/EN/parts/info/13547556118
.
However, I received an Exception of:
Fatal error: Uncaught exception 'Zend_Uri_Exception' with message 'Path "/bmw/EN/parts/info/http://www.etk.cc/bmw/EN/parts/info/Throttle housing Assy/13547556118/" is not a valid HTTP path'
It is believed that URL Rewrite changed the URL to http://www.etk.cc/bmw/EN/parts/info/Throttle housing Assy/13547556118/
but the phpQuery or Zend library does not recognize the URL Rewrite.
How do I resolve this issue (loading the correct URL)?
Note: I can't use the URL after URL Rewrite, as the URL contains the product name & has no pattern.
Here is my solution.
I first use the following codes to obtain the header of the request:
From the
Location:
header, I can know the rewritten URL. Then, I use thephpQuery
again to obtain the required information using the newly obtained rewritten URL.Footnote: I do think the Exception in the question is a bug in phpQuery.