# Path: collectors/pubmed/spider.py
# class Spider(CrawlSpider):
# 
#     # Public
# 
#     name = 'pubmed'
#     allowed_domains = ['eutils.ncbi.nlm.nih.gov']
# 
#     def __init__(self, conf=None, conn=None, date_from=None, date_to=None):
# 
#         # Save conf/conn
#         self.conf = conf
#         self.conn = conn
# 
#         # Make start urls
#         self.start_urls = _make_start_urls(
#             prefix='https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi/',
#             template='https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi/?db=pubmed&id={pmid}&retmode=xml',
#             date_from=date_from, date_to=date_to)
# 
#         # Set parser
#         self.parse = parse_record
# 
#         # Inherit parent
#         super(Spider, self).__init__()


from scrapy.crawler import CrawlerProcess
from .spider import Spider
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals



# Module API

def collect(conf, conn, date_from=None, date_to=None):
    process = CrawlerProcess(conf['SCRAPY_SETTINGS'])

# Path: collectors/pubmed/spider.py
# class Spider(CrawlSpider):
# 
#     # Public
# 
#     name = 'pubmed'
#     allowed_domains = ['eutils.ncbi.nlm.nih.gov']
# 
#     def __init__(self, conf=None, conn=None, date_from=None, date_to=None):
# 
#         # Save conf/conn
#         self.conf = conf
#         self.conn = conn
# 
#         # Make start urls
#         self.start_urls = _make_start_urls(
#             prefix='https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi/',
#             template='https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi/?db=pubmed&id={pmid}&retmode=xml',
#             date_from=date_from, date_to=date_to)
# 
#         # Set parser
#         self.parse = parse_record
# 
#         # Inherit parent
#         super(Spider, self).__init__()


# Path: collectors/pubmed/collector.py
from scrapy.crawler import CrawlerProcess
from .spider import Spider

# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals



# Module API

def collect(conf, conn, date_from=None, date_to=None):
    process = CrawlerProcess(conf['SCRAPY_SETTINGS'])

    process.crawl(Spider, conn=conn, date_from=date_from, date_to=date_to)