Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Shell Script in GeekTool trouble ...
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Dysfunction" data-source="post: 940816" data-attributes="member: 51052"><p>Ok, lets break this down....</p><p></p><p>[code]</p><p>curl [url=http://m.wund.com/global/stations/94975.html]Weather Underground (Mobile)[/url]</p><p>[/code]</p><p>gets that page.</p><p></p><p>the sed -n '21p' parses out the following...</p><p></p><p>[code]</p><p>mikeMbp:~ mike$ cat wundweather.tst |sed -n '21p'</p><p> <span class="nowrap"><b>14</b>°C</span></p><p>mikeMbp:~ mike$ </p><p>[/code]</p><p>sed -e 's/<span class="nowrap"><b>//g' and sed -e 's/<\/b.*//g' are line substitution strings so the first gets us </p><p>[code]</p><p>mikeMbp:~ mike$ cat wundweather.tst |sed -n '21p'|sed -e 's/<span class="nowrap"><b>//g'</p><p> 14</b>°C</span></p><p>[/code]</p><p>and the second gets us </p><p>[code]</p><p>mikeMbp:~ mike$ cat wundweather.tst |sed -n '21p'|sed -e 's/<span class="nowrap"><b>//g'| sed -e 's/<\/b.*//g' </p><p> 14</p><p></p><p></p><p>[/code]</p><p>Now, if your OTHER page is not identically laid out.. you'll have to change your sed statements to match. I have to go pick my kids up from school, I'll check when I get back and play with that one if need be.</p></blockquote><p></p>
[QUOTE="Dysfunction, post: 940816, member: 51052"] Ok, lets break this down.... [code] curl [url=http://m.wund.com/global/stations/94975.html]Weather Underground (Mobile)[/url] [/code] gets that page. the sed -n '21p' parses out the following... [code] mikeMbp:~ mike$ cat wundweather.tst |sed -n '21p' <span class="nowrap"><b>14</b>°C</span> mikeMbp:~ mike$ [/code] sed -e 's/<span class="nowrap"><b>//g' and sed -e 's/<\/b.*//g' are line substitution strings so the first gets us [code] mikeMbp:~ mike$ cat wundweather.tst |sed -n '21p'|sed -e 's/<span class="nowrap"><b>//g' 14</b>°C</span> [/code] and the second gets us [code] mikeMbp:~ mike$ cat wundweather.tst |sed -n '21p'|sed -e 's/<span class="nowrap"><b>//g'| sed -e 's/<\/b.*//g' 14 [/code] Now, if your OTHER page is not identically laid out.. you'll have to change your sed statements to match. I have to go pick my kids up from school, I'll check when I get back and play with that one if need be. [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Shell Script in GeekTool trouble ...
Top