带有gtk/webkit/jswebkit的呈现/交互式javascript
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了带有gtk/webkit/jswebkit的呈现/交互式javascript相关的知识,希望对你有一定的参考价值。
# This is a downloader middleware that can be used to get rendered javascript pages using webkit. # # this could be extended to handle form requests and load errors, but this is the bare bones code to get it done. # # the advantage over the selenium based approachs I've seen is that it only makes one request and you don't have to set up selenium. import gtk import webkit import jswebkit class WebkitDownloader( object ): def process_request( self, request, spider ): if( type(request) is not FormRequest ): webview = webkit.WebView() webview.connect( 'load-finished', lambda v,f: gtk.main_quit() ) webview.load_uri( request.url ) gtk.main() js = jswebkit.JSContext( webview.get_main_frame().get_global_context() ) renderedBody = str( js.EvaluateScript( 'document.documentElement.innerHTML' ) ) return HtmlResponse( request.url, body=renderedBody ) # Snippet imported from snippets.scrapy.org (which no longer works) # author: jdwilson # date : Sep 06, 2011
以上是关于带有gtk/webkit/jswebkit的呈现/交互式javascript的主要内容,如果未能解决你的问题,请参考以下文章
带有 NumberPicker 的 AlertDialog 呈现不正确
反应使用 dangerouslySetInnerHTML 来呈现带有 html 标签的 json