How can I run a html file from terminal? [closed]

爱⌒轻易说出口 提交于 2021-02-17 19:19:49

问题


I have a html file that titled test.html this is the file:

<!DOCTYPE html>
<html>
<body onload="document.getElementById('saveForm').click();">
<form method="post" enctype="multipart-form-data" name="my_form" onsubmit="clearTextBoxCounter()" action="http://xxxxx" >

  <input type=hidden name=teks value=><center><b>KIRIM SMS GRATIS</b></center><br><br>
Nomer HP:<br />
  <input class="field text small" type="text" maxlength="20" name="Phonenumbers" value="085642383165"/>
  <br />

<br />
Isi Pesan:<br />
  <textarea rows="5" cols="20" onKeyPress=check_length(this.form); onKeyDown=check_length(this.form); name=Text >testing pesan 2</textarea>
<br />

<input id="saveForm" class="btTxt" type="submit" value="KIRIM" name="TOMBOL" />

</body>
</html>

as you can see when the file is loaded it automatically clicks the submit button, and redirects it to http://xxxxxx how can I run this html file from terminal? I'm using this on openwrt with webserver installed on it.


回答1:


For those like me, who have reached this thread because they want to serve an html file from linux terminal or want to view it using a terminal command, use these steps:-

1)If you want to view your html using a browser:-
Navigate to the directory containing the html file
If you have chrome installed, Use:-

google-chrome <filename>.html


                OR
Use:-

firefox <filename>.html

2)If you want to serve html file and view it using a browser
Navigate to the directory containing the html file
And Simply type the following on the Terminal:-

pushd <filename>.html; python3 -m http.server 9999; popd;


Then click the I.P. address 0.0.0.0:9999 OR localhost:9999 (Whatever is the result after executing the above commands). Or type on the terminal :-

firefox 0.0.0.0:9999


Using the second method, anyone else connected to the same network can also view your file by using the URL:- "0.0.0.0:9999"




回答2:


You could always use the Lynx terminal-based web browser, which can be got by running $ sudo apt-get install lynx.

With Lynx, I believe the file can then be viewed using lynx <filename>




回答3:


This works :

browsername <filename>

Example: google-chrome index.html




回答4:


Skip reading the html and use curl to POST whatever form data you want to submit to the server.




回答5:


It is possible to view a html file from terminal using lynx or links. But none of those browswers support the onload javascript feature. By using lynx or links you will have to actively click the submit button.




回答6:


You can make the file accessible via a web server then you can use curl or lynx




回答7:


I think what you want is simply this.

Open the terminal

Navigate to the directory containing the HTML file

And simply type: browse (your file name) without the parentheses of course.

This will run your HTML file in Firefox browser.




回答8:


we could open html file from linux/unix by using firefox .html




回答9:


python -mhtmllib test.html or curl http://www.comanyname.com/somepage.html|python -mhtmllib -



来源:https://stackoverflow.com/questions/27760105/how-can-i-run-a-html-file-from-terminal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!