I need a shell script to get a public password for VPN from a site (which refreshes the password everyday more or less). The password is a HTML table, in a specific line of the HTML code of the web page. Once that I've retrieved the password (a word made of 5 characters) I'd like to put it at the end of a simple text file. I'd need a script like this to automatically update the password in my OpenWrt-based router's OpenVPN client.
This is the webpage I'm talking about, and this is line number 265, where the password is (there are two instances of the password, doesn't matter which one the script chooses:
<td>1<td>in1.vpnjantit.com<td>53,992,1194,25000<td><a href='http://www.vpnjantit.com/assets/in1.vpnjantit.com.zip'>in1.vpnjantit.com.zip</a><td>vpnjantit.com<td>x3bu7<td>2018-03-31 at 22:00<tr><tr><td>2<td>in2.vpnjantit.com<td>53,443,1194,25000<td><a href='http://www.vpnjantit.com/assets/in2.vpnjantit.com.zip'>in2.vpnjantit.com.zip</a><td>vpnjantit.com<td>x3bu7<td>2018-03-31 at 22:00<tr></table></div>
The file where I want to put the password it will be very simple:
vpnjantit.com
passwd
The first line is the username, and it will always be the same: "vpnjantit.com". The second line is the 5 characters password. I'd need that the script first deletes the second line of the file, and then it puts the password from the html file on the second line (replace the old password with the new one).
I looked around, and tried to do something with a sequency of awk, curl, cat and other commands, but I wasn't able to get the desired result. Really have no idea about how to realize this.
Thank you a lot in advance for any advice!