Skip to content
Advertisement

How i scrape Flipkart Product comments review by php?

JavaScript

Error: get blank page of flipkart.

Any help much appreciated.

Thanks In Advance

Advertisement

Answer

please read this https://stackoverflow.com/a/1732454/1067003 and come back. read it? good, now here’s a decent alternative: DOMDocument. now you’ve solved your first problem, trying to parse HTML with regex.

your second problem, is that this website does not serve the reviews themselves in the html, but rather fetches the reviews via javascript. the obvious course of action then is to start digging into the internal api the javascript use to fetch the comments. do that, and you’ll probably find the url https://www.flipkart.com/api/3/page/dynamic/product-reviews , where the javascript is fetching the comments from. however, replicating the the javascript request with curl, you’ll probably get a 403 Forbidden error, until you figure out that you must fake the custom x-user-agent header to match whatever you put in CURLOPT_USERAGENT. doing that, you’ll probably end up with something like this:

JavaScript

which outputs:

JavaScript

EDIT: didnt paste the whole code first time around x.x

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement