Curl or Webservice Running Javascript

Asked

Viewed 629 times

0

I have a chronic problem, I need a CURL request to execute codes also in Javascript.

Generally speaking, all posts and references point to the same answer, that Curl does not have the ability to execute code in Javascript, however I have already found API’s in Java that ran the CURL function promising to run code in Javascripts (such as HTML Unit, for example)however I noticed that these API’s were abandoned by the developers.

I would need something in this sense, because I need to interact that sites making requests via Javascript.

It is no use to see the request by the browser and put it on Curl, this Javascript code aims precisely to prevent the interaction by webservices, creating Javascript keys that are sent to the server to release the next request.

In short, I need some API, code, Facility or technology that can simulate a browser by enabling Curl requests but running Javascripts as promised by this Htmlunit api.

The ideal would be in PHP language, but I believe it does not exist, in the absence of JAVA solves.

Could someone please assist me in this problem?

  • Let me understand. You want CURL to call the server that will return some content. I didn’t understand when Javascript should run why. Will this javascript already be on the server or will it be sent by CURL? What exactly javascript will do and what exactly the server should return?

  • Many websites place code in javascript to prevent robots from accessing data or posting certain posts. For example, sending as a given hiddem in a web form a code generated dynamically in the browser, is a way to make sure that is a user accessing. If CURL could run javascript it would generate this code and return this post as a perfect browser. It is no use to study the generated code, the algorithm, besides complex, changes all the time making the site can not be accessed via Curl, as the judicial sites for example or even google.

1 answer

0


A cool way to emulate browsers is via Selenium using Java, C#, Ruby, Python or Javascript with Nodejs. This allows you to perform operations in an emulated web browser.

It’s usually used for testing, but it might suit your case. But then its application would be no different than a robot and could be used for beneficial or non-beneficial purposes.

  • Yes, because it emulates a browser like all functions (it will possibly run Java Script), is it possible to exchange data through its commands? the same way we do at CURL? because my goal is to capture and exchange information with the websites interacting with my system (it is written in PHP, but I can run a java in the background saving in BD), is that possible? if you’ve ever worked with him, is there any code examples for me to get an idea? Thanks in advance, don’t know how hard it is to find that answer.

  • It’s my friend, looking over the top here yes, it seems possible that this API solves my problem, I will now be on this vacation working with them to try to learn how to use it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.