--- layout: page2 title: PiScrape - Text-Only Hotspot Information --- [Git Repository](https://git.pickmy.org/nq4t/piscrape) PiScrape allows you to display your connected reflectors/talkgroups in a small webpage you can embed, like this: It does this by scraping the Pi-Star dashboard for the information using a shell script and php page. It can be run on any webserver with PHP and SSH access to your Pi-Star. It can also be run entirely on Pi-Star if you open web ports or reverse proxy. The original version ran on a locally hosted web-server that could pull the dashboard directly. But I also had success running it on remote web-servers that could SSH in to the Pi-Star. Remote SSH execution is not yet included in the repository; but if you know how to do that, you probably can write that small script yourself. The current implementation is running entirely on the PiStar via nginx reverse proxy. The PHP page itself largely just calls the shell script, which returns the HTML code containing your connection info. When the script is executed; it pulls either the repeaterstatus frame from the dashboard or the Brandmeister API page. Then using a series of awk and sed commands, the information is extracted and output. ### Bash Script ```bash #!/bin/bash #.013 alpha # de NQ4T (nq4tango@gmail.com) # SET THE HOSTNAME OR IP OF YOUR HOTSPOT! pidmr=192.168.1.10 # I HAVE TWO SO I SET TWO #pidstar=192.168.1.11 # grab copy of rendered bm_links.php from hotspot, convert HTML to newline, filter by "TG", remove timeslot info, convert to one line # check contents to see if we need to display 'no groups' message # if you are not using DMR, then comment these two lines out # to comment out, just add a pound-sign to the start of the line, like these comments. dmr=$(curl -s http://$pidmr/mmdvmhost/bm_links.php| sed 's/<[^>]\+>/\n/g' | grep '^TG' | sed 's/TG/#/g'| sed 's/(.)//g' | sed ':a;N;$!ba;s/\n/ - /g') [ -z "$dmr" ] && dmr="No Talkgroups Found" # do the same for dstar with repeaterinfo.php but just egrep for reflector prefix, strip HTML, keep the first 8 characters # check to see if we need to display not linked # if you are not using D-Star, comment these next two lines out. if you don't, the script will take longer to run. # If you modify what egrep looks for, you may get other modes to work. #dstar=$(curl -s http://$pidstar/mmdvmhost/repeaterinfo.php | egrep "REF|XRF|DCS|XLX" | sed 's/<[^>]\+>//g' | cut -b 1-8) #[ -z "$dstar" ] && dstar="Not Linked" # HTML for table cells on hotspot.php page. These are all one line even if they look like two in your editor. # This is for a 2x2 table using DMR and D-Star #printf "BM TG:\n$dmr
\nD-Star:\n$dstar
\n" # This is for a DMR only display. printf "BM TG:\n$dmr
\n" # This is for a D-STar Only Display # printf "D-Star:\n$dstar
\n" ``` The script iself is commented pretty well to explain how it works. Minimal modification is required for operation. The main requirement is you can either access the dashboard from the system running the script, or can remotely execute the script on a machine that can. Since putting your Pi-Star's dashboard on the internet is risky without reverse proxy; remote execution via SSH and key-based authentication is recommended. The script's output is literally pre-formatted HTML: ``` pi-star@pi-star(rw):~$ ./piscrape.sh BM TG: #3151 #98003
``` The PHP executes the script, stuffs this information in the proper place, as well as adding a time-stamp: ```php NQ4T Hotspot Info
NQ4T Pi-Star Hotspot Network

Current Connections:

Listed connections do not mean I have a radio on or am at a radio.
This is especially true for Brandmeister.

For informational purposes only.

73 de NQ4T
``` Most of this was actually based off of [Pi-StAPrS](https://nq4t.com/software/pistaprs) and was designed to be embedded in a QRZ profile page. Full source code is available in the [repository](https://git.pickmy.org/nq4t/piscrape).