V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  zuroc  ›  全部回复第 4 页 / 共 11 页
回复总数  219
1  2  3  4  5  6  7  8  9  10 ... 11  
2012-12-14 16:48:21 +08:00
回复了 keakon 创建的主题 Tornado Tornado + Supervisor + nginx 怎样优雅地重启?
2012-12-14 15:23:26 +08:00
回复了 kenneth 创建的主题 Python 想爬取hao123上的所有网站,有没有好的方法?
2012-12-14 15:22:12 +08:00
回复了 kenneth 创建的主题 Python 想爬取hao123上的所有网站,有没有好的方法?
2012-12-10 00:25:06 +08:00
回复了 pinkman 创建的主题 问与答 请问python和ruby谁写爬虫更方便好使
code for example

#coding:utf-8
from spider.spider import route, Handler, spider
import _env
from os.path import abspath, dirname, join
from operator import itemgetter

PREFIX = join(dirname(abspath(__file__)))
HTTP = 'http://www.ecocn.org/%s'

@route('/portal\.php')
class portal(Handler):
def get(self):
for link in self.extract_all('<dt class="xs2"><a href="', '"'):
spider.put(HTTP%link)


@route('/article-\d+-\d+.html')
class article(Handler):
def get(self):
link = self.extract( 'class="pn" href="', '" target=""> 中英对照')
spider.put(HTTP%link)


@route('/forum\.php')
class forum(Handler):
from mako.lookup import Template
template = Template(filename=join(PREFIX, 'template/rss.xml'))

page = []

def get(self):
name = self.extract('id="thread_subject">', '</a>')
if not name:
return
name = name.split(']', 1)[-1].strip()
html = self.extract('<div class="t_fsz">', '<div id="comment_')
html = html[:html.rfind('</div>')]
tid = int(self.get_argument('tid'))
print tid, name
self.page.append((tid, self.request.url, name, html))

@classmethod
def write(cls):
page = cls.page
page.sort(key=itemgetter(0), reverse=True)
with open(join(PREFIX, 'ecocn_org.xml'), 'w') as rss:
rss.write(
cls.template.render(
rss_title='经济学人 . 中文网',
rss_link='http://www.ecocn.org',
li=[
dict(
link=link,
title=title,
txt=txt
) for id, link, title, txt in cls.page
]
)
)


if __name__ == '__main__':
spider.put('http://www.ecocn.org/portal.php?mod=list&catid=1')
#10个并发抓取线程 , 网页读取超时时间为30秒
spider.run(10, 30)
forum.write()
2012-12-10 00:23:51 +08:00
回复了 pinkman 创建的主题 问与答 请问python和ruby谁写爬虫更方便好使
2012-11-28 12:30:24 +08:00
回复了 zuroc 创建的主题 程序员 写给WEB程序员的打分表
@ispinfx fixed
2012-11-08 15:41:46 +08:00
回复了 flylee2011 创建的主题 云计算 有用又拍云的战长吗? 请教又拍云的表单api的使用
swfupload 在ie9下有bug

用我ppt里面的js代码就可以了
2012-09-29 13:09:53 +08:00
回复了 zuroc 创建的主题 Python 仿造notepad.cc写了一个网站 , 附上详细的教程 (python vs tornado)
@kojp
@qiayue

教程 , 不搞太复杂
1  2  3  4  5  6  7  8  9  10 ... 11  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2323 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 30ms · UTC 08:21 · PVG 16:21 · LAX 01:21 · JFK 04:21
Developed with CodeLauncher
♥ Do have faith in what you're doing.