这是我想刮的代码
<li id="shortlink">
<strong>Short link:</strong>
<input id="short-link-input" type="text" value="http://tnydu.biz/DfBCAEk" onclick="dbzglobal_event_adapter();">
</li>我使用的脚本如下:
shortlink=soup.select("#short-link-input value")
print shortlink但是它提供了[]输出,我不能提取它的链接。找到和选择可用的方法。有人能帮忙吗?
发布于 2014-02-02 19:06:45
尝尝这个
elem = soup.find('input',{'id':'short-link-input'})
print elem.get('value')发布于 2014-02-02 19:06:36
试试这个:
shortlink=soup.select("#short-link-input")[0]['value']select-method返回元素列表。要获得属性值,必须调用其get-method或使用该属性的名称作为键索引。
https://stackoverflow.com/questions/21514833
复制相似问题