admin管理员组

文章数量:1321245

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.

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.

Share Improve this question asked Dec 11, 2011 at 10:54 Simon GelfandSimon Gelfand 612 silver badges3 bronze badges 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". – user166390 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 – pho 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. – Shea 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. – aequalsb Commented Nov 29, 2016 at 4:49
Add a ment  | 

1 Answer 1

Reset to default 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.

本文标签: Disable Javascript in Curl Request (PHP)Stack Overflow