Tobi
Tobi

Reputation: 13

curl utf-8 special character after download

When I use curl with this link to find the current artist and title:

curl -H 'Cache-Control: no-cache' -t utf-8 \
    -s http://www.radiopilatus.ch/livecenter?action=webradio \
   | grep "Jetzt Läuft" -A3 | tail -n 1

The output is both the artist and title - e.g.:

STEFANIE HEINZMANN
DIGGIN' IN THE DIRT

it should just be the title - e.g.:

DIGGIN' IN THE DIRT

How can the title be returned (without the artist)?

Edit:

yes this is correct, The <br> is not my problem. I have not see here is automatic changed from :

enter image description here

- How can change to correct output?

Upvotes: 0

Views: 181

Answers (1)

Sᴀᴍ Onᴇᴌᴀ
Sᴀᴍ Onᴇᴌᴀ

Reputation: 8297

It appears that the call/pipe to grep finds the line containing both the artist and title, with a break tag (i.e. <br>) between the two.

enter image description here

In order to only show the title, you may need to use a string function (e.g. sed) to remove the contents before the break tag.

curl -H 'Cache-Control: no-cache' -t utf-8 -s http://www.radiopilatus.ch/livecenter?action=webradio | grep "Jetzt Läuft" -A3 | tail -n 1 |sed -e 's/.*<br>//'

You can see this in action on Teh (PHP) Playground.

Upvotes: 1

Related Questions