English 中文(简体)
摘自html网页,壳
原标题:Getting text from html page, shell
  • 时间:2011-02-01 21:11:46
  •  标签:
  • shell

我正试图从一页的炮弹中提取文字,作为说明我当地气温的文字的一部分。

然而,我可以把如何妥善使用灰 to带上头。

摘录

</div><div id="yw-forecast" class="night" style="height:auto"><em>Current conditions as of 8:18 PM GMT</em><div id="yw-cond">Light Rain Shower</div><dl><dt>Feels Like:</dt><dd>6 &deg;C</dd><dt>Barometer:</dt><dd style="position:relative;">1,015.92 mb and steady</dd><dt>Humidity:</dt><dd>87 %</dd><dt>Visibility:</dt><dd>9.99 km</dd><dt>Dewpoint

减幅

<dt>Feels Like:</dt><dd>6 &deg;C</dd>

ying6°C

我尝试了各种不同的策略,包括 gr和 a。 伤者能否帮助我解救?

最佳回答

提 出

grep -o -e "<dd>.*deg;C</dd>" the_html.txt

单页:

-e PATTERN, --regexp=PATTERN
      Use PATTERN as  the  pattern.   This  can  be  used  to  specify
      multiple search patterns, or to protect a pattern beginning with
      a hyphen (-).  (-e is specified by POSIX.)

...

-o, --only-matching
      Print only the matched (non-empty) parts  of  a  matching  line,
      with each such part on a separate output line.

如果您希望删除<条码>、d>和</d>。 另见-b 5-12

问题回答

引证:

grep -Po  (?<=Feels Like:</dt><dd>).*?(?=</dd>)  | sed  s/ &deg;/°/ 

结果:

6°C

如果X是你的输入档案,而超文本来源则按你的书写方式定期编排,这应当做到:

∗∗∗∗∗∗∗∗

牙齿





相关问题
KornShell- Creating a fixed width text file

I need to create a simple fixed width text file in KornShell (ksh). My current attempt using printf to pad the string isn t working out very well. What s the shortest, cleanest way to create a fixed ...

unix find command

how to use the find command to find files/directories which are not matching the pattern. for eg: find <some options > -name "dontfile.txt" should give me output of all the find whose file ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

1. 露台式照像

在Windows XP中,没有一时出现指挥时,是否有办法操作一种灰色文字? 我常常需要把“善待”(工作)与“灰色”同起来,即使我的文字没有产出,......

热门标签