我怎样才能提取在bash HTML TD? [英] How can I extract td from html in bash?

查看:121
本文介绍了我怎样才能提取在bash HTML TD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查询后的伦敦code从GEONAMES数据:

I am querying London postcode data from geonames:

HTTP://www.geonames。 ?组织/邮政code-search.html q =伦敦和放大器;国家GB =

我想转输出逼到后code标识符(贝斯纳尔格林,伊斯灵顿等)的列表。什么是bash中只提取名称的最好方式?

I want to turn the output into a list of just the postcode identifiers (Bethnal Green, Islington, etc.). What is the best way to extract just the names in bash?

推荐答案

我不知道,如果你的意思是这个 \\ n 分隔列表(或一个在支架和逗号分隔)

I'm not sure if you mean this \n delimited list (or one in brackets and comma delimited)

html='http://www.geonames.org/postalcode-search.html?q=london&country=GB'
wget -q "$html" -O - |
  w3m -dump -T 'text/html'|
    sed -nr 's/^ +[0-9]+ +(.*) +[A-Z]+[0-9]+ +United Kingdom.*/\1/p'

的w3m 是:WWW浏览的寻呼机具有优良的表/帧的支持

输出(第10行)

London Bridge   
Kilburn         
Ealing          
Wandsworth      
Pimlico         
Kensington      
Leyton          
Leytonstone     
Plaistow        
Poplar          

这篇关于我怎样才能提取在bash HTML TD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆