test.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. import os, sys,time,datetime
  4. import urllib
  5. import requests
  6. from mongoengine import register_connection, PointField, DynamicDocument, StringField
  7. import simplejson as json
  8. from django.db.models.fields import DateTimeField
  9. PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
  10. sys.path.insert(0, PROJECT_ROOT)
  11. os.environ.setdefault("DJANGO_SETTINGS_MODULE", "configs.testing")
  12. from script.base import init_env
  13. init_env(interactive = False)
  14. from apps.web.core.db import Searchable
  15. register_connection(alias = 'spider',
  16. name = 'spider',
  17. host = '116.62.228.194',
  18. port = 27017,
  19. username = 'dba',
  20. password = 'dayuan@2020..',
  21. authentication_source = 'admin')
  22. def get_shops_info(lat,lng):
  23. url = 'https://u.zhinengxiyifang.cn/api/Stores/findNearStoreInc'
  24. payload = {"lat":lat,"lont":lng,"skip":0,"limit":10}
  25. # url = 'https://www.baidu.com'
  26. # payload = {}
  27. proxies = {'http':'http://140.246.89.239:19382','https':'https://140.246.89.239:19382'}
  28. strhtml = requests.post(url, json = payload,proxies = proxies,timeout = 15).text
  29. result = json.loads(strhtml)
  30. return result
  31. # cookies = {
  32. # 'JSESSIONID':'0626C177663F8C8D0D18D212DB4EF04F',
  33. # 'AppName':'%u6C5F%u897F%u7F8E%u5929%u65B0%u80FD%u6E90%u79D1%u6280%u6709%u9650%u516C%u53F8'
  34. # }
  35. # url = 'https://1.yugu.net.cn/api/v1/agent/query_detail.htm' # 'https://1.yugu.net.cn/api/v1/agent/detail.htm'
  36. #
  37. # data = {'id':"327"}
  38. # strhtml = requests.post(url,json = data,headers = {'Authorization':'Bearer 2e8d745bae1e4a4561aacb2a4a733d9aade8'},verify=False,timeout = 15).text
  39. # result = json.loads(strhtml)
  40. # url = 'http://cdz.gpsserver.cn/ChargeCarSys?gtel=68000000423'
  41. # strhtml = requests.get(url,timeout = 15).text
  42. # result = json.loads(strhtml)
  43. # url = 'http://ydc.youdianchong.com:8087/newCloseCharger?longitude=112.85811&latitude=35.496819'
  44. # url = 'https://1.yugu.net.cn/api/v1/agent/query_detail.htm' # 'https://1.yugu.net.cn/api/v1/agent/detail.htm'
  45. #
  46. # data = {'id':"327"}
  47. # strhtml = requests.get(url,headers = {'openId':'ozk7Zv4WC5akrk9Lvrm78jggwHk4'},verify=False,timeout = 15).text
  48. # result = json.loads(strhtml)
  49. import base64
  50. import sys
  51. import json
  52. import base64
  53. # 打印文字
  54. print('aaa')