2

Is there a way to disable Javascript in a Curl request in PHP ?

Trying to mimic a browser request (from a browser with Javascript disabled)

Could this be done via a header/user agent/cookie ?

Thanks.

4
  • 3
    This doesn't make sense. curl doesn't know about/care about/understand JavaScript: see Does curl support JavaScript? If you want to make sure the UA/other headers align, then use a tool like Fiddler2 to see what (your) "normal browser" sends, and then read the curl documentation for how to send it "exactly like the browser". Commented Dec 11, 2011 at 10:55
  • 1
    cURL doesn't look at javascript at all. To cURL, the entire page is just a blob of text, so whether it has only html, javascript, xml, or anything else, curl will behave the same Commented Dec 11, 2011 at 11:06
  • 2
    If you mean that you are using cURL as sort of a proxy, where it requests a page, and then outputs it as-is, then you need to remove all <script></script> tags, and anything between them, before it is outputted. Commented Dec 11, 2011 at 11:14
  • no... he means when the target URL removes content with jabascript until the user interacts somehow and triggers the content. however, when javascript is disabled in the browser, the content is delivered normally. i have experienced this occasionally -- for example, clicking a "i am over 18 years old" button on a vaping website... or any age-restricted website. pinterest is another example. so, it is not related to whether cURL processes javascript -- but rather how cURL will NOT react to javascript needed to render the content. Commented Nov 29, 2016 at 4:49

1 Answer 1

7

Is there a way to disable Javascript in a Curl request in PHP ?

Yes, there is: Simply leave everything as it is. :)

Curl will not interpret Javascript. Actually, the big challenge is to build automated, curl-based clients that do interpret Javascript.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.