【发布时间】:2010-09-25 05:40:47
【问题描述】:
我正在尝试使用以下示例代码获取网页:
from urllib import urlopen
print urlopen("http://www.php.net/manual/en/function.gettext.php").read()
现在我可以在一个变量中获取整个网页。我想要页面的一部分包含这样的内容
<div class="methodsynopsis dc-description">
<span class="type">string</span><span class="methodname"><b>gettext</b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$message</tt></span>
)</div>
这样我就可以生成一个文件以在另一个应用程序中实现。 我希望能够提取单词“string”、“gettext”和“$message”。
【问题讨论】:
-
在 SO 上已多次询问此问题的变体。这是确定的答案:stackoverflow.com/questions/1732348/…