I have found this software very useful. I am now trying to crawl a website that is only accessed when there is a certain cookie stored in my browser. The website does this to present information specific to a city selected. Is there a way I could mimic this cookie in my phpcrawl code?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"Injecting" cookies is not supported directly by phpcrawl (yet).
But a little workaround should do the trick:
Within your extended crawler-class, just overrdie the constructor and place your cookie into the internal cookie-array.
So if your code now looks like this and you want to add a cookie for the site www.anysite.net with the name "cookie_name" and the value "cookie_value"
// ... classMyCrawlerextendsPHPCrawler{function__construct(){parent::__construct();$this->pageRequest->cookies["anysite.net"]["cookie_name"]="cookie_value";// Use "anysite.net" here, NOT "www.anysite.net"}functionhandlePageData(&$page_data){//...}}// ...
Hope it works for you!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have found this software very useful. I am now trying to crawl a website that is only accessed when there is a certain cookie stored in my browser. The website does this to present information specific to a city selected. Is there a way I could mimic this cookie in my phpcrawl code?
Hi,
"Injecting" cookies is not supported directly by phpcrawl (yet).
But a little workaround should do the trick:
Within your extended crawler-class, just overrdie the constructor and place your cookie into the internal cookie-array.
So if your code now looks like this and you want to add a cookie for the site www.anysite.net with the name "cookie_name" and the value "cookie_value"
replace it with this one:
Hope it works for you!