forgetTb 最近的时间轴更新
forgetTb

forgetTb

V2EX 第 163888 号会员,加入于 2016-03-18 15:08:16 +08:00
forgetTb 最近回复了
@golmic 1, 需要的是实时响应,类似 scrapyrt(realtime, nonblocking)这种。但 scrapyrt 是使用 Twisted 做 WebServer,并不能与 newrelic(:一种服务器监控软件)搭配使用。现在想使用 Tornado 做 WebServer(支持 newrelic,且异步)。
@crb912 Tornado 做 webserver (可以用 newrelic 做服务器监控), 调用 scrapy 项目的爬虫并实时响应返回。( scrapyrt 是用 Twisted 做 Webserver:不能够与 newrelic 搭配使用 XXX )
或者说能够使用 tornado.platform.twisted
具体是在 Tornado 框架下
import tornado.platform.twisted
tornado.platform.twisted.install()
from twisted.internet import reactor

调用 Scrapy 启动爬虫(EvenvLoop 事件循环的代码)
dfd = process.crawl(QuotesSpider)
# process.start() # the script will block here until the crawling is finished d.addBoth(lambda _: reactor.stop())
result = dfd.addCallback(self.result_items)
并且直接拿到爬取数据。

参考链接如下:
https://stackoverflow.com/questions/36384286/how-to-integrate-flask-scrapy
http://www.tornadoweb.org/en/stable/twisted.html#twisted-on-tornado
https://doc.scrapy.org/en/latest/topics/practices.html
2016-09-18 13:52:11 +08:00
回复了 ammzen 创建的主题 问与答 在中国人民银行官网发现这样一行代码
@ammzen ,你是如何解决的,可以具体详细的解说下吗?我在别的网站上也碰到了这个问题。
我用 python 的 requests 去请求一个网址,总是返回那一段代码。是可以设置 selenium 参数开启 javascript 吗?
用浏览器访问时,第一次访问时弹出那框,然后关闭后再刷新,再访问就正常了。
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1013 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 19:22 · PVG 03:22 · LAX 12:22 · JFK 15:22
Developed with CodeLauncher
♥ Do have faith in what you're doing.