Home > Enterprise >  Curl: login on a webpage, and clicking a button (not a form)
Curl: login on a webpage, and clicking a button (not a form)

Time:07-26

I have a html page with a button like that :

<button type="button" ><div>somediv</div></button>

And with curl, I want to access this page, login, and click on this button.

I've found solution to login, keep my cookie, and use it again.

But I'm stuck at clicking on this button. When I click on this button, it opens an app (with an app url, like myAppId://restOfTheUrl[...]). But I don't want to execute curl with this url, I want to click on the button, and get the url that opens the app.

I've found curl request to do post request on a form ( cURL and click a button in a website ), but I don't have a form, just a button. And my element does not have a name, so I don't know how to click on this button.

What I have now is :

curl --netrc-file loginFile https://myUrl.com/ -cookie-jar ./cookie

Then I know I can use --cookie cookie to use my cookie, but I can't figure out the rest.

CodePudding user response:

cURL is a library and command line program for making network (primarily HTTP) requests.

You can't use it to click on things.

You can work out what clicking on something would do and, if that something is "make an HTTP request", write code that uses cURL to make that HTTP request.

In this case, that something is not "make an HTTP request" so the usefulness of cURL is at an end.

You need to take a step back and use whatever tool you are using to drive cURL to drive the application that you want to open instead.

  • Related