Commit a9a22760 authored by 马超's avatar 马超

Upload New File

parent edc95ec4
{
"createdAt": "2025-04-02T09:24:15.067Z",
"updatedAt": "2025-04-02T10:50:38.000Z",
"id": "TxcqhO3oQgLzu2LF",
"name": "tw_search_no_fy",
"active": true,
"nodes": [
{
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nlet output_info = {};\nlet text_info = {};\ninfo = JSON.parse($('Webhook').item.json.body.info).full_text.replace(/https:\\/\\/[^\\s]+/g, '').replaceAll(/[ \\t\\n\\r]+/g, ' ').replaceAll(\"\\\"\", '” ');\n// console.log(info);\nuser_id = JSON.parse($('Webhook').item.json.body.info).id;\ntext_info['full_text'] = info;\noutput_info['text'] = JSON.stringify(text_info);\noutput_info['msg_info'] = info;\noutput_info['user_id'] = user_id;\nreturn output_info;"
},
"id": "ef5d2483-7f69-4ed8-9eb4-22bd2129cbcc",
"name": "get_info",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-380,
1020
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "CALL insert_news_source_no_fy({{ (JSON.stringify($json.data))}},{{ JSON.stringify(JSON.stringify($json.label_data)) }},{{ JSON.stringify(JSON.stringify($json.artificial_label_data)) }});",
"options": {}
},
"id": "e97de582-6a3c-4871-8357-4764e0d49f44",
"name": "insert_city_news",
"type": "n8n-nodes-base.mySql",
"typeVersion": 2.4,
"position": [
300,
1020
],
"credentials": {
"mySql": {
"id": "YpVIiGwzmmkf7vR7",
"name": "SL-DB-PRD"
}
}
},
{
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nresult_data = $input.all();\ncontent_all = {};\n// console.log(result_data);\n// console.log(content_all);\ninfo_data_list = JSON.parse($('Webhook').all()[0].json.body.info);\nschedule_id = $('Webhook').all()[0].json.body.schedule_id;\nfull_text_origial = info_data_list.full_text.replace(/https:\\/\\/[^\\s]+/g, '');\n// full_text_origial = result_data[0].json.msg_info;\ninfo_data_list['full_text'] = full_text_origial\ninfo_data_list['full_text_ch'] = full_text_origial;\noutput_all = [];\noutput_all_data = {};\noutput_news_data_str = \"\";\noutput_news_url_data_str = \"\";\nfull_text_new = info_data_list.full_text.replace(/'/g, \"\").replace(/\"/g, \"\");\nfull_text_ch_new = info_data_list.full_text_ch.replace(/'/g, \"\").replace(/\"/g, \"\");\nnews_item_data = \"\";\nnews_item_data = news_item_data+\"(\";\nnews_item_data += \"'\"+full_text_new+\"'\";\nnews_item_data += ',';\nnews_item_data += \"'\"+full_text_ch_new+\"'\";\nnews_item_data += ',';\nnews_item_data += \"'\"+info_data_list.url+\"'\";\nnews_item_data += ',';\nnews_item_data += \"'\"+info_data_list.name+\"'\";\nnews_item_data += ',';\nnews_item_data += \"'\"+info_data_list.screen_name+\"'\";\nnews_item_data += ',';\nnews_item_data += \"'\"+info_data_list.profile_image_url+\"'\";\nnews_item_data += ',';\nnews_item_data += \"'0'\";\nnews_item_data += ',';\nnews_item_data += \"'\"+info_data_list.favourite_count+\"'\";\nnews_item_data += ',';\nnews_item_data += \"'\"+info_data_list.retweet_count+\"'\";\nnews_item_data += ',';\nnews_item_data += \"'\"+info_data_list.view_count+\"'\";\nnews_item_data += ',';\nnews_item_data += \"'zh_cn'\";\nnews_item_data += ',';\nnews_item_data += 'STR_TO_DATE(\\''+info_data_list.created_at+'\\',\\'%Y-%m-%d %H:%i:%s\\')';\nnews_item_data += ',';\nnews_item_data += \"'\"+info_data_list.id+\"'\";\nnews_item_data += ',';\nnews_item_data += \"'\"+schedule_id+\"'\";\nnews_item_data += ',';\nnews_item_data += \"'twitter_search'\";\nnews_item_data += ',';\nnews_item_data += \"'0'\";\nnews_item_data += ',';\nnews_item_data += \"'0'\";\nnews_item_data += ',';\nnews_item_data += \"'1'\";\nnews_item_data += ')';\ncity_code = info_data_list.city_code;\nitem_data = \"(\";\nitem_data += \"'\"+city_code+\"'\";\nitem_data += ',';\nitem_data += '@last_insert_id';\nitem_data += '),';\noutput_news_data_str += item_data;\nimages_url = info_data_list.images_url;\nvideos_url = info_data_list.videos_url;\nfunction isEmptyString(value) {\n // 方法1: 直接检查是否为空字符串或null\n if (!value || value.trim() == '' || value.trim() == 'null' || value.trim() == 'None') {\n return true;\n }\n return false;\n};\nfor (let i = 0; i < images_url.length; i++) {\n image_url_data = images_url[i];\n original_url = image_url_data.original_url;\n thumbnail_url = image_url_data.thumbnail_url;\n if(isEmptyString(original_url) && isEmptyString(thumbnail_url)){\n continue;\n }else{\n image_item_data = \"(\";\n image_item_data += \"'\"+original_url+\"'\";\n image_item_data += ',';\n if(isEmptyString(thumbnail_url)){\n image_item_data += null;\n }else{\n image_item_data += \"'\"+thumbnail_url+\"'\";\n }\n image_item_data += ',';\n image_item_data += '0';\n image_item_data += ',';\n image_item_data += '@last_insert_id';\n image_item_data += '),';\n output_news_url_data_str += image_item_data;\n }\n};\nfor (let i = 0; i < videos_url.length; i++) {\n video_url = videos_url[i];\n video_item_data = \"(\";\n video_item_data += \"'\"+video_url+\"'\";\n video_item_data += ',';\n video_item_data += null;\n video_item_data += ',';\n video_item_data += '2';\n video_item_data += ',';\n video_item_data += '@last_insert_id';\n video_item_data += '),';\n output_news_url_data_str += video_item_data;\n};\nif(output_news_url_data_str.length == 0){\n output_news_url_data_str = \"('','','',''),\"\n}\noutput_all_data['city_data'] = output_news_data_str.slice(0,output_news_data_str.length-1);\noutput_all_data['urls_data'] = output_news_url_data_str.slice(0,output_news_url_data_str.length-1);\noutput_all_data['news_data'] = news_item_data;\noutput_all_data['news_id'] = info_data_list.id;\noutput_all_data_temp = {};\noutput_all_data_temp['data'] = JSON.stringify(output_all_data);\noutput_all_data_temp['label_data'] = [];\noutput_all_data_temp['artificial_label_data'] = [];\noutput_all.push(output_all_data_temp);\nreturn output_all;"
},
"id": "b88a5eb3-682e-41c3-a0a1-5707602fe4df",
"name": "get_city_news_sql",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-40,
1020
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "update news_source set likes = {{ JSON.parse( $('Webhook').item.json.body.info).favourite_count }} ,forward = {{ JSON.parse( $('Webhook').item.json.body.info).retweet_count }},hot = {{ JSON.parse( $('Webhook').item.json.body.info).view_count }} where news_uid = {{ JSON.stringify(JSON.parse( $('Webhook').item.json.body.info).id) }}\n",
"options": {}
},
"id": "c6d87581-cc17-4e51-8988-ec9834b358d1",
"name": "update_city_news",
"type": "n8n-nodes-base.mySql",
"typeVersion": 2.4,
"position": [
-380,
1560
],
"credentials": {
"mySql": {
"id": "YpVIiGwzmmkf7vR7",
"name": "SL-DB-PRD"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"id": "a1541edc-9637-4ac2-83a6-902ee9d29af6",
"leftValue": "={{ $json.count.toString() }}",
"rightValue": "=0",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "eb2519df-1655-4f93-a217-90100ade157f",
"name": "insert_or_update",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
-780,
1280
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "select IFNULL(count(id), 0) as count from news_source where news_uid ={{JSON.stringify(JSON.parse($json.body.info).id) }};\n",
"options": {}
},
"id": "2e1ae342-37d7-483f-ab96-1b0bf1555532",
"name": "is_exists_news",
"type": "n8n-nodes-base.mySql",
"typeVersion": 2.4,
"position": [
-1020,
1280
],
"alwaysOutputData": false,
"credentials": {
"mySql": {
"id": "YpVIiGwzmmkf7vR7",
"name": "SL-DB-PRD"
}
}
},
{
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nresult_data = $input.all();\ninfo_data_list = JSON.parse($('Webhook').all()[0].json.body.info);\noutput_news_data_str = '';\noutput_all_data = {};\noutput_all = [];\noutput_city_code_list = [];\ncity_code = info_data_list.city_code;\noutput_city_code_list.push(city_code);\noutput_all_data['city_code'] = output_city_code_list;\noutput_all_data['news_id'] = info_data_list.id;\noutput_all.push(output_all_data);\nconsole.log(output_all);\nreturn output_all;"
},
"id": "529aff1a-17a4-41a0-bfbe-6b9291f2fc31",
"name": "get_city_code_info",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-380,
1300
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "CALL insert_news_city({{ JSON.stringify(JSON.stringify($json.city_code))}},{{ JSON.stringify(JSON.stringify($json.news_id)) }});",
"options": {}
},
"id": "823030a0-715c-4da8-a036-a57b97d39d7c",
"name": "insert_city_data",
"type": "n8n-nodes-base.mySql",
"typeVersion": 2.4,
"position": [
-40,
1300
],
"credentials": {
"mySql": {
"id": "YpVIiGwzmmkf7vR7",
"name": "SL-DB-PRD"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "CALL record_craw_zh_counts({{JSON.stringify(($json.body.info.parseJson().removeField(\"full_text\").toJsonString()))}},{{JSON.stringify(JSON.stringify($json.body.schedule_id)) }});",
"options": {}
},
"id": "0daa36c2-30fc-4ca7-9c3c-f7d02074b9be",
"name": "record_zh_info",
"type": "n8n-nodes-base.mySql",
"typeVersion": 2.4,
"position": [
-1020,
1020
],
"credentials": {
"mySql": {
"id": "YpVIiGwzmmkf7vR7",
"name": "SL-DB-PRD"
}
}
},
{
"parameters": {
"httpMethod": "POST",
"path": "twitter/search/nofy",
"authentication": "headerAuth",
"options": {
"allowedOrigins": "*",
"rawBody": false
}
},
"id": "6bf7acc2-de8e-45d7-9a80-d637d90ef554",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
-1280,
1280
],
"webhookId": "e495a29c-8f43-4175-bdb8-277e03b60b07",
"credentials": {
"httpHeaderAuth": {
"id": "U87Wvnvu9oQ5Zapo",
"name": "Header Auth account"
}
}
}
],
"connections": {
"get_info": {
"main": [
[
{
"node": "get_city_news_sql",
"type": "main",
"index": 0
}
]
]
},
"get_city_news_sql": {
"main": [
[
{
"node": "insert_city_news",
"type": "main",
"index": 0
}
]
]
},
"insert_or_update": {
"main": [
[
{
"node": "get_info",
"type": "main",
"index": 0
}
],
[
{
"node": "update_city_news",
"type": "main",
"index": 0
},
{
"node": "get_city_code_info",
"type": "main",
"index": 0
}
]
]
},
"is_exists_news": {
"main": [
[
{
"node": "insert_or_update",
"type": "main",
"index": 0
}
]
]
},
"get_city_code_info": {
"main": [
[
{
"node": "insert_city_data",
"type": "main",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "is_exists_news",
"type": "main",
"index": 0
},
{
"node": "record_zh_info",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"meta": {
"templateCredsSetupCompleted": true
},
"pinData": {},
"versionId": "6eb0ee01-ee98-4461-8c83-c608499db81d",
"triggerCount": 1,
"shared": [
{
"createdAt": "2025-04-02T09:24:15.077Z",
"updatedAt": "2025-04-02T09:24:15.077Z",
"role": "workflow:owner",
"workflowId": "TxcqhO3oQgLzu2LF",
"projectId": "C7zKoCDdmGgzUqSW",
"project": {
"createdAt": "2024-08-23T06:31:21.275Z",
"updatedAt": "2024-08-23T06:41:43.608Z",
"id": "C7zKoCDdmGgzUqSW",
"name": "周 卫 <zhouwei@ssish.com>",
"type": "personal",
"projectRelations": [
{
"createdAt": "2024-08-23T06:31:21.275Z",
"updatedAt": "2024-08-23T06:31:21.275Z",
"role": "project:personalOwner",
"userId": "3f0021b4-d0a7-4db6-af21-5ef829c47882",
"projectId": "C7zKoCDdmGgzUqSW",
"user": {
"createdAt": "2024-08-23T06:31:16.119Z",
"updatedAt": "2025-03-19T06:19:26.514Z",
"id": "3f0021b4-d0a7-4db6-af21-5ef829c47882",
"email": "zhouwei@ssish.com",
"firstName": "周",
"lastName": "卫",
"personalizationAnswers": {
"companyType": "education",
"role": "business-owner",
"automationBeneficiary": "my-team",
"companySize": "20-99",
"reportedSource": "friend",
"version": "v4",
"personalization_survey_submitted_at": "2024-08-23T06:57:52.856Z",
"personalization_survey_n8n_version": "1.55.3"
},
"settings": {
"userActivated": true,
"firstSuccessfulWorkflowId": "s6zsznwVs6N4L2Hx",
"userActivatedAt": 1725957335278,
"npsSurvey": {
"responded": true,
"lastShownAt": 1742365155724
},
"isOnboarded": true
},
"role": "global:owner",
"disabled": false,
"mfaEnabled": false,
"isPending": false,
"isOwner": true
}
}
]
}
}
],
"tags": []
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment