Giter Site home page Giter Site logo

str's Introduction

处理http response

拿到response之后,进行各种处理

通过一些简单的代码处理string(一般来自于http请求)

  • select a, b, c from json // 如果要处理的string是json格式,则返回属性为a,b,c的新object(如果json是数组,则返回对象数组,相当于map),可以通过as重命名属性
  • select replace(a, '1', '2') from json //从json中读取a属性,并将1替换成2
  • insert into demo () values() // 将数据写入到demo表中,没有表则创建表
  • download from xxx // xxx必须是string,或者string[], 将下载这些内容
  • request getAttr('#xxx', 'href')
  • select text('a') from (select b from datasource) // 支持复合查询,比如json的属性值是html (完成一半,目前功能是通过2次执行实现的);支持子查询
  • select text('.content') from dom if exist('#xxx') then goto getAttr('#xxx', 'href'), loop();

期望实现的功能

html

Text / Html

当context是元素时,方法可以不用传元素选择器

  • select text('#id1') from context // 当context是element时 在element下找到id="id1"的元素,返回text 等价于 select text() from (select element("#id1") from context)
  • select text() from context // 当context是element时 返回element的text
  • select html('.class1') from context // 当context是element时 在element下找到class="class1"的元素,返回html
  • select html() from context // 当context是element时 返回element的html

GetAttr

  • select getattr("a", "href") from context // 返回a标签的href值
  • select getattr("href") from context // 当getattr只有一个参数时,context必须是element

Json

Jobject

输入:属性名,至少一个参数 输出:object/object[]

  • select jobject(a, b, c) from context // 如果要处理的string是json格式,则返回属性为a,b,c的新object(如果json是数组,则返回对象数组,相当于map),可以通过as重命名属性
  • select jobject(a) from context // -- 至少要有1个参数 返回类型:object

Jtext

输入:属性名,仅接受一个参数 输出:string

  • select jtext(a) from context // 读取json的a属性,返回类型:string

需要解决的问题

  • 嵌套查询
  • 内容分割,的转义

str's People

Contributors

sigeer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.