M Shahzad Khan
M Shahzad Khan

Reputation: 935

simple html dom return wrong html

I am try to scrap a website http://www.pricegrabber.com/. I am using simple html dom library for it. I used simple html dom for a lot of scrapping sites, it work perfectly for me, but on this site it return wrong html, which I can't see in normal browser when I navigate to that page. I think it return its mobile version site html.

enter image description here

While the original site is different.I tried it through CURL as well, but it return empty result. Not sure why, may be they have some restrictions on their site. Wanted to know if I am missing anything. Cause the html it returns (picture added), is missing alot of html elements which I need to scrap.

Any help will be appreciated. Thanks

Upvotes: 0

Views: 218

Answers (1)

Sabuj Hassan
Sabuj Hassan

Reputation: 39375

It is because you didn't instruct the curl to handle 302, 301 redirect things. It can be done like this way, and it will return you html

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

Also, for avoid the mobile content, you can use a browser to your header like this way.

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0');

Upvotes: 1

Related Questions