V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  lyxint  ›  全部回复第 6 页 / 共 8 页
回复总数  158
1  2  3  4  5  6  7  8  
@kojp 正则比单纯的字符串操作慢, beatifulsoup那就更慢了. beautifulsoup累死累活建了dom树, 你只取<p>和</p>之间的内容, 太浪费了.

真想用什么库, 那就HTMLParser (beautifulsoup也用了), 很简单.
2012 年 1 月 12 日
回复了 shunai 创建的主题 程序员 linux 下写php什么编辑器比较爽?
vim, aptana, komodo edit
index.html是wget http://news.sina.com.cn/ 存到本地的
@fature 字符串下标操作比re要慢??? 不可能的.

让数据说话.

http://gist.github.com/1595083.js?file=test.py

http://gist.github.com/1595083.js?file=result
<script src="https://gist.github.com/1595083.js"> </script>
用张教主的txt_wrap_by_all
def txt_wrap_by(begin, end, html):
if not html:
return ''
start = html.find(begin)
if start >= 0:
start += len(begin)
end = html.find(end, start)
if end >= 0:
return html[start:end].strip()

def txt_wrap_by_all(begin, end, html):
if not html:
return ''
result = []
from_pos = 0
while True:
start = html.find(begin, from_pos)
if start >= 0:
start += len(begin)
endpos = html.find(end, start)
if endpos >= 0:
result.append(html[start:endpos].strip())
from_pos = endpos+len(end)
continue
break
return result

ps = txt_wrap_by_all('<p>', '</p>', html)
python的要加re.DOTALL这个flag, 不然会漏结果
看得我云里雾里啊,好多名词。
2012 年 1 月 7 日
回复了 em91 创建的主题 macOS secureCRT过期了,mac下还有啥可以用rz命令么
netcat
2012 年 1 月 3 日
回复了 daqing 创建的主题 程序员 Rabel - Project Babel 2 on Rails - 预览版上线
@daqing 那应该是不推荐, 而不是不支持
2012 年 1 月 3 日
回复了 daqing 创建的主题 程序员 Rabel - Project Babel 2 on Rails - 预览版上线
不支持windows是何来的? rails不能跑在windows上吗?
2012 年 1 月 3 日
回复了 gujiaxi 创建的主题 Linux 你觉得哪个Linux发行版的Logo最好看呢?
2012 年 1 月 3 日
回复了 Livid 创建的主题 Project Babel 新功能 - 特别关注
怎么知道谁follow了自己啊?
2012 年 1 月 3 日
回复了 gujiaxi 创建的主题 Linux 你觉得哪个Linux发行版的Logo最好看呢?
Linux Distro Logos Collections

http://fossilet.users.sourceforge.net/gnulinux/distro-logos.en.html

redhat的红帽子logo挺酷的呀, http://fossilet.users.sourceforge.net/images/dl/redhat.png

BSD系列的也都很酷
2012 年 1 月 3 日
回复了 gujiaxi 创建的主题 Linux 你觉得哪个Linux发行版的Logo最好看呢?
没人觉得redhat很酷么
2012 年 1 月 1 日
回复了 GordianZ 创建的主题 V2EX 2012 New Year's resolution 新年计划
1. 去看看大地上的事
2. 能多看一些书籍
3. 锻炼身体
2012 年 1 月 1 日
回复了 bcxx 创建的主题 天黑以后 20120101 午夜俱乐部
新年快乐大家:-)
1  2  3  4  5  6  7  8  
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1203 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 27ms · UTC 23:22 · PVG 07:22 · LAX 16:22 · JFK 19:22
♥ Do have faith in what you're doing.