123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- """
- @author: luojunhui
- """
- import time
- import json
- import pymysql
- import requests
- trace_id = "search-5b5343dc-b6a8-4f65-9e6b-e04b9961e530-1716955405"
- sql = f"""select trace_id, article_title, article_text, gh_id, account_name from long_articles_video where trace_id = '{trace_id}';"""
- connection = pymysql.connect(
- host="rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com", # 数据库IP地址,内网地址
- port=3306, # 端口号
- user="crawler", # mysql用户名
- passwd="crawler123456@", # mysql用户登录密码
- db="piaoquan-crawler", # 数据库名
- charset="utf8mb4" # 如果数据库里面的文本是utf8编码的,charset指定是utf8
- )
- cursor = connection.cursor()
- cursor.execute(sql)
- out_video_list = cursor.fetchall()
- result = out_video_list[0]
- params = {
- "trace_id": result[0],
- "title": result[1],
- "ghId": result[3],
- "content": result[2],
- "accountName": result[4]
- }
- # print(params)
- url = "http://localhost:8111/re_search_videos"
- a = time.time()
- header = {
- "Content-Type": "application/json",
- }
- response = requests.post(url, json=params, headers=header, timeout=600)
- b = time.time()
- print(response.text)
- print(b - a)
- print(json.dumps(response.json(), ensure_ascii=False, indent=4))
|