You are not logged in.

#1 2019-05-15 10:08:32

CanadianClubXXX
Member
From: Barcelona
Registered: 2019-04-23
Posts: 21

help - automate click HTML page using command line tool

Hi,

I would like to be able to click on a button/anchor in an html page using some kind of command line tool. I am experimenting with lynx and it's fantastic. I can login in a page, click on the second link, enter in a form, fill it and send... all via automated command line scripts, using something like

lynx "http://mywebpage.php" -accept_all_cookies -cmd_script=steps_data.txt

where steps_data.txt is a textfile with the instructions (with link to click on, with fields I will fill, etc...).

But the final step of my scrits needs to click a buttom that has some javascript when you click on it. It's a page like that:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML XMLNS="https://www.w3.org/1999/xhtml">

  <HEAD>
    <META charset="utf-8"> 
    <META http-equiv="Content-Type" content="text/html;">
    
	<script>
	function clickat() {
		alert("clicat !");
	}
	</script>
</head>	

<body>

	<form name="marcajes" method="post" onsubmit="destination.php">
			<h1>Troublesome command line problem</h1>
			<input type="hidden" name="accion" id="accion" value="">
			<input type="submit" style="display:none;" id="confirmar2" />
			<input type="button" style="display:none;" id="confirmar" onclick="javascript:clickat();" />
			
			<ul> 
			   <li>opcio 1</li>
			   <li>opcio 2</li>
			   <li><a href="#" style="font-size:1.2em;" onclick="document.getElementById('accion').value='finalitzacio';document.getElementById('confirmar').click();">THIS!!!!</a></li>
			   <li>opcio 4</li>
			</ul>
	</form>

</body>
</html>

I can solve the problem with Java or PHP using something like Selenium. But in my crusade to learn as much as I can about command line tools.... it would be great to solve this with curl, lynx, wget or similar...

thx in advance !

Offline

#2 2019-05-17 04:54:17

ohnonot
...again
Registered: 2015-09-29
Posts: 3,830
Website

Re: help - automate click HTML page using command line tool

the addition of javascript makes the whole problem much, much harder and you should think thrice whether you can't solve the problem differently.

If you really can't, you need to look at software like phantomjs.
i am using it (optional) in my weather conky. i am not good with anything js. lots of searching of stackoverflow questions etc. was required.

Offline

#3 2019-05-17 07:01:52

earlybird
ほやほや
Registered: 2015-12-16
Posts: 710
Website

Re: help - automate click HTML page using command line tool

elinks has some basic JavaScript support.

Offline

#4 2019-05-22 11:13:20

CanadianClubXXX
Member
From: Barcelona
Registered: 2019-04-23
Posts: 21

Re: help - automate click HTML page using command line tool

I think I will try with Selenium. Or even continue using an standard browser (it's only 3 clicks using my mobile phone).

Thx !

Offline

Board footer

Powered by FluxBB