12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- """
- @author: luojunhui
- """
- import time
- import json
- import pymysql
- import requests
- trace_id = "search-08fa6f87-aaa2-4462-9f57-f5ca72219136-1716827402"
- 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))
|