在Azure Logic应用中解析文本 [英] Parse text in Azure Logic Apps

查看:77
本文介绍了在Azure Logic应用中解析文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建 Azure Logic App ,它将不断在Internet上请求特定的网站并解析收到的HTML.

I want to create Azure Logic App which will constantly request a specific website on the Internet and parse received HTML.

我已经创建了Logic App,并设置了时间间隔和HTTP请求操作.

I've created Logic App and set up interval and HTTP request action.

对于HTML代码上的简单正则表达式操作,我应该选择哪个操作下一步?

Which action should I choose as the next step for simple regex operation on HTML code?

我想到的是创建 Azure函数可以胜任这项工作,但我想知道是否还有其他解决方案更适合此类任务.

What comes to my mind is creating Azure Function which will do the job, but I wonder if there is any other solution, more suitable for such task.

我希望它尽可能简单.

只是发现了一些很酷的功能. Logic Apps包含一些基本类型的基本表达式.

Just found out some cool feature. Logic Apps contain some basic expressions for primitive types.

幸运的是,它缺少任何regexstring.contains.

Unfortunetly it lacks of any regex or string.contains.

现在,我将尝试使用Azure Functions.

For now, I'll try with Azure Functions.

推荐答案

我已经设法通过使用

I've managed to solve my problem with use of Workflow Definition Language and building blocks provided by Azure.

Azure函数的想法还不错,并且可以完美地适用于任何更复杂的情况,但是正如我提到的,我希望它尽可能简单,所以就在这里.

The Azure Function idea was not that bad and would fit perfectly for any more complex case, but as I mentioned, I wanted it as simple as possible, so here it is.

这就是我现在的样子.

出于完整性考虑,以下是JSON格式的流

For sake of completeness, here is the flow in JSON format

{
    "$connections": {
        "value": {
            "wunderlist": {
                "connectionId": "/subscriptions/.../providers/Microsoft.Web/connections/wunderlist",
                "connectionName": "wunderlist",
                "id": "/subscriptions/.../providers/Microsoft.Web/locations/northeurope/managedApis/wunderlist"
            }
        }
    },
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Condition": {
                "actions": {
                    "Create_a_task": {
                        "inputs": {
                            "body": {
                                "completed": false,
                                "list_id": 000000000,
                                "starred": true,
                                "title": "@{variables('today date')}"
                            },
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['wunderlist']['connectionId']"
                                }
                            },
                            "method": "post",
                            "path": "/tasks",
                            "retryPolicy": {
                                "type": "none"
                            }
                        },
                        "limit": {
                            "timeout": "PT20S"
                        },
                        "runAfter": {},
                        "type": "ApiConnection"
                    },
                    "Set_a_reminder": {
                        "inputs": {
                            "body": {
                                "date": "@{addHours(utcNow(), 3)}",
                                "list_id": 000000,
                                "task_id": "@body('Create_a_task')?.id"
                            },
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['wunderlist']['connectionId']"
                                }
                            },
                            "method": "post",
                            "path": "/reminders",
                            "retryPolicy": {
                                "type": "none"
                            }
                        },
                        "limit": {
                            "timeout": "PT20S"
                        },
                        "runAfter": {
                            "Create_a_task": [
                                "Succeeded"
                            ]
                        },
                        "type": "ApiConnection"
                    }
                },
                "expression": "@contains(body('HTTP'), variables('today date'))",
                "runAfter": {
                    "Initialize_variable": [
                        "Succeeded"
                    ]
                },
                "type": "If"
            },
            "HTTP": {
                "inputs": {
                    "method": "GET",
                    "uri": "..."
                },
                "runAfter": {},
                "type": "Http"
            },
            "Initialize_variable": {
                "inputs": {
                    "variables": [
                        {
                            "name": "today date",
                            "type": "String",
                            "value": "@{utcNow('yyyy/MM/dd')}"
                        }
                    ]
                },
                "runAfter": {
                    "HTTP": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "Recurrence": {
                "recurrence": {
                    "frequency": "Day",
                    "interval": 1,
                    "startTime": "2017-08-01T23:55:00Z",
                    "timeZone": "UTC"
                },
                "type": "Recurrence"
            }
        }
    }
}

这篇关于在Azure Logic应用中解析文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆