12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- # -*- coding: utf-8 -*-
- # !/usr/bin/env python
- import os, sys,time,datetime
- import urllib
- import requests
- from mongoengine import register_connection, PointField, DynamicDocument, StringField
- import simplejson as json
- from django.db.models.fields import DateTimeField
- PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
- sys.path.insert(0, PROJECT_ROOT)
- os.environ.setdefault("DJANGO_SETTINGS_MODULE", "configs.testing")
- from script.base import init_env
- init_env(interactive = False)
- from apps.web.core.db import Searchable
- register_connection(alias = 'spider',
- name = 'spider',
- host = '211.159.224.10',
- port = 27119,
- username = 'service',
- password = 'oOzjoQcO5DyyiN97AY0NpzJ6vztjNpx5',
- authentication_source = 'admin')
- class zhiyichongSeller(Searchable):
- meta = {
- 'collection': 'zhiyichong_seller',
- 'db_alias': 'spider',
- }
-
- # 根据二维码编号,获取设备更详细的信息
- logicalFormat1 = 'XC%04d'
- logicalFormat2 = 'XC%05d'
- url1 = 'https://wx.isfdz.com/users/getInfo?id=1703433&srcId=200&sellerId=%s'
- # cookie1 = 'PHPSESSID=289df6867a76371820780cdbedce0397; PHPSESSID=289df6867a76371820780cdbedce0397; acw_tc=76b20ff916492062843861607e6040a09702c48cd1884b1201c1389a7b9c14'
- agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x63060012)'
- #36000-80000
- newCount = 0
- ii = 0
- for ii in range(3000):
- try:
- url = url1 % ii
- response = requests.get(url)
-
- devDict = json.loads(response.text)
- if 'operatorPhone' not in devDict['data']:
- print 'over -----------------------'
- continue
- zhiyichongSeller.get_collection().update({'operatorPhone':devDict['data']['operatorPhone']},{'$set':devDict['data']},upsert = True)
- print ii
- except Exception,e:
- print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!',e
- continue
- print('OK')
|