functions.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. """
  2. @author: luojunhui
  3. """
  4. import requests
  5. import pymysql
  6. class Functions(object):
  7. """
  8. functions class
  9. """
  10. @classmethod
  11. def getTitleScore(cls, title_list, account_name):
  12. """
  13. 标题打分
  14. :param title_list:
  15. :param account_name:
  16. :return:
  17. """
  18. url = "http://192.168.100.31:6060/score_list"
  19. body = {
  20. "account_nickname_list": [account_name],
  21. "text_list": title_list,
  22. "max_time": None,
  23. "min_time": None,
  24. "interest_type": "avg",
  25. "sim_type": "mean",
  26. "rate": 0.1
  27. }
  28. response = requests.post(url=url, headers={}, json=body).json()
  29. return response
  30. @classmethod
  31. def matchLinkById(cls, channel_content_id):
  32. """
  33. Use channelContentId to match articleUrl
  34. :param channel_content_id:
  35. :return:
  36. """
  37. connection = pymysql.connect(
  38. host='rm-bp12k5fuh5zyx31d28o.mysql.rds.aliyuncs.com',
  39. port=3306,
  40. user='wx2023_ad',
  41. password='wx2023_adP@assword1234',
  42. db='adplatform',
  43. charset='utf8mb4'
  44. )
  45. sql = f"""select account_id, link, item_index from changwen_article where id = '{channel_content_id}';"""
  46. cursor = connection.cursor()
  47. cursor.execute(sql)
  48. article_link = cursor.fetchone()
  49. return article_link