| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
dwd4
10年前发布

网页内容抓取工具:ReactiPy

ReactiPy  是 Python 的模块,用来将 React 组件渲染成 HTML 内容。它支持快速加载网页、使搜索引擎更快的抓取网页内容,以达到 SEO 优化的目的。

代码示例:

from reactipy.component import ReactComponent  import os        class HelloWorldComponent(ReactComponent):      path = os.path.join(          os.path.dirname(os.path.abspath(__file__)),          'components/helloworld.js')     component = HelloWorldComponent()     component.render(props=['Hello', 'World'])

Documentation

Installation

pip install reactipy

ReactComponent

Define Component

Define a react component that includes a path pointing to the path of the React Component. JSX is not supported so make sure to compile your jsx templates to js.

from reactipy.component import ReactComponent class HelloWorldComponent(ReactComponent):      path = 'path/to/component.js' 

*** You must specify a path when defining a React Component ***

Create Instance

Create an instance of the component and optionally specifiy a container which will output an id on the component and props_name which will be a global variable that has all the props specified in json

component = HelloWorldComponent(container='helloworld', props_name='HELLO_PROPS')

Arguments:

  • container: [optional] the id of the container.
  • props_name:[optional] the props variable name.

Render Component

Render a component to html on the initial request for faster page loads and to allow search engines to crawl your pages for SEO purposes.

component.render(info=['hello', 'world]) 

Arguments:

  • kwargs: [optional] the props

项目主页:http://www.open-open.com/lib/view/home/1427853387256

 本文由用户 dwd4 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1427853387256.html
ReactiPy 网络爬虫