http_test.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import requests
  2. from mysql_db import MysqlDB
  3. headers_1 = {'content-type': "application/json", 'Authorization': 'APP appid = 4abf1a,token = 9480295ab2e2eddb8',
  4. 'dsNo': 'source1'}
  5. headers_2 = {'content-type': "application/json",
  6. 'Authorization': 'APP appid = 4abf1a,token = 9480295ab2e2eddb8',
  7. 'dsNo': 'source2',
  8. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, '
  9. 'like Gecko) Chrome/86.0.4240.111 Safari/537.36',
  10. 'Host': '101.132.43.32:5308',
  11. 'POST': '/news/queryNewsByPage HTTP/1.1',
  12. 'Connection': 'keep-alive',
  13. 'Accept': 'application/json;charset=UTF-8'
  14. }
  15. if __name__ == '__main__':
  16. import time
  17. mysql = MysqlDB('marketing_db')
  18. url = "https://api-uat3.elaber.cn/elab-marketing-content/materialLabel/markingForMaterial"
  19. sql_dict = {
  20. 1: 'select a.id from house a LEFT JOIN brand_house_rlat b on a.id = b.house_id where a.status = 1 and b.status = 1 and b.brand_id = 1',
  21. 2: 'select a.id from content_moment a LEFT JOIN brand_house_rlat b on a.house_id = b.house_id where a.status = 1 and b.status = 1 and b.brand_id = 1',
  22. 3: 'select a.id from t_content_album a LEFT JOIN brand_house_rlat b on a.house_id = b.house_id where a.status = 1 and b.status = 1 and b.brand_id = 1',
  23. 4: 'select a.id from content_layout a LEFT JOIN brand_house_rlat b on a.house_id = b.house_id where a.status = 1 and b.status = 1 and b.brand_id = 1'
  24. }
  25. for index in sql_dict.keys():
  26. house = mysql.select(sql_dict.get(index))
  27. count = 0
  28. for x in house:
  29. print(x[0])
  30. params = {
  31. "deleteStatus": 2,
  32. "materialId": x[0],
  33. # 物料类型,1:项目,2:视频,3:图集(图片),4:户型
  34. "materialType": index,
  35. "user": "batch20201230"
  36. }
  37. response = requests.post(url, json=params, headers=headers_1)
  38. print(response.text)
  39. time.sleep(0.5)