# Path: jd/proxymanager.py
# class ProxyManager(object):
#     def __init__(self):
#     def update_proxy(self, count = 100):
#     def push_proxy(self, proxy):
#     def get_proxy(self):
#     def delete_proxy(self, proxy):


import sys
import chardet
import re
import json
import datetime
import logging
import config
import utils
from scrapy import Spider
from scrapy import Request
from ..proxymanager import proxymng



reload(sys)
sys.setdefaultencoding('utf-8')


# python manage.py runspider -a url=https://item.jd.com/11478178241.html -a name=jd
class JDCommentSpider(Spider):
    name = 'jd_comment'

    def __init__(self, name = None, **kwargs):
        super(JDCommentSpider, self).__init__(name, **kwargs)
        self.url = kwargs.get("url")
        self.guid = kwargs.get('guid', 'guid')
        self.product_id = kwargs.get('product_id')
        # self.url = 'https://item.jd.com/11478178241.html'
        # self.url = 'https://item.jd.com/4142680.html'
        # self.url = 'https://item.jd.com/3133859.html'
        # self.url = 'https://item.jd.com/3995645.html'
        # self.product_id = 3995645
        self.log('product_id:%s' % self.product_id)
        self.item_table = 'item_%s' % self.product_id
        self.urls_key = '%s_urls' % self.product_id

        self.log_dir = 'log/%s' % self.product_id
        self.is_record_page = False

        self.sql = kwargs.get('sql')
        self.red = kwargs.get('red')

# Path: jd/proxymanager.py
# class ProxyManager(object):
#     def __init__(self):
#     def update_proxy(self, count = 100):
#     def push_proxy(self, proxy):
#     def get_proxy(self):
#     def delete_proxy(self, proxy):


# Path: jd/spiders/jd_comment.py
import sys
import chardet
import re
import json
import datetime
import logging
import config
import utils
from scrapy import Spider
from scrapy import Request
from ..proxymanager import proxymng




reload(sys)
sys.setdefaultencoding('utf-8')


# python manage.py runspider -a url=https://item.jd.com/11478178241.html -a name=jd
class JDCommentSpider(Spider):
    name = 'jd_comment'

    def __init__(self, name = None, **kwargs):
        super(JDCommentSpider, self).__init__(name, **kwargs)
        self.url = kwargs.get("url")
        self.guid = kwargs.get('guid', 'guid')
        self.product_id = kwargs.get('product_id')
        # self.url = 'https://item.jd.com/11478178241.html'
        # self.url = 'https://item.jd.com/4142680.html'
        # self.url = 'https://item.jd.com/3133859.html'
        # self.url = 'https://item.jd.com/3995645.html'
        # self.product_id = 3995645
        self.log('product_id:%s' % self.product_id)
        self.item_table = 'item_%s' % self.product_id
        self.urls_key = '%s_urls' % self.product_id

        self.log_dir = 'log/%s' % self.product_id
        self.is_record_page = False

        self.sql = kwargs.get('sql')
        self.red = kwargs.get('red')

        proxymng.red = self.red