Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jadbin committed Oct 25, 2017
1 parent 2cd0cf2 commit 4494a5d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 17 deletions.
16 changes: 15 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@
Change log
==========

0.7.1 (2017-?-?)
----------------

New features
~~~~~~~~~~~~


Update
~~~~~~

- ``xpaw.utils.run`` 模块中 ``run_crawler`` 函数移动至 ``xpaw.run`` 模块
- 合并utils为一个模块


0.7.0 (2017-10-24)
------------------

New features
~~~~~~~~~~~~

- 使用继承Dupefilter的去重过滤器来实现去重功能,系统配置新增 ``dupefilter_cls`` 项,用于替换默认的去重过滤器
- ``xpaw.utils`` 模块中新增 ``run_crawler`` 函数,便于在python代码中控制开启爬虫
- ``xpaw.utils.run`` 模块中新增 ``run_crawler`` 函数,便于在python代码中控制开启爬虫

Update
~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion tests/test_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json
import random

from xpaw import HttpRequest
from xpaw.http import HttpRequest
from xpaw.downloader import Downloader, DownloaderMiddlewareManager
from xpaw.downloadermws import CookieJarMiddleware

Expand Down
2 changes: 1 addition & 1 deletion xpaw/config/__init__.py → xpaw/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections import MutableMapping
import types

from . import defaultconfig
from xpaw import defaultconfig

CONFIG_PRIORITIES = {
"default": 0,
Expand Down
File renamed without changes.
17 changes: 17 additions & 0 deletions xpaw/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# coding=utf-8

from os.path import isfile, join, abspath

from xpaw.config import Config
from xpaw.cluster import LocalCluster
from xpaw.utils import configure_logging


def run_crawler(project_dir, **kwargs):
if not isfile(join(project_dir, "setup.cfg")):
raise FileNotFoundError("Cannot find 'setup.cfg' in {}".format(abspath(project_dir)))

config = Config(kwargs, priority="project")
configure_logging("xpaw", config)
cluster = LocalCluster(project_dir, config)
cluster.start()
14 changes: 0 additions & 14 deletions xpaw/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import logging
from importlib import import_module
from pkgutil import iter_modules
from os.path import isfile, join, abspath
import string

from xpaw.config import Config
from xpaw.cluster import LocalCluster


def load_object(path):
dot = path.rindex(".")
Expand Down Expand Up @@ -107,13 +103,3 @@ def render_templatefile(path, **kwargs):

def string_camelcase(s):
return _camelcase_invalid_chars.sub('', s.title())


def run_crawler(project_dir, **kwargs):
if not isfile(join(project_dir, "setup.cfg")):
raise FileNotFoundError("Cannot find 'setup.cfg' in {}".format(abspath(project_dir)))

config = Config(kwargs, priority="project")
configure_logging("xpaw", config)
cluster = LocalCluster(project_dir, config)
cluster.start()

0 comments on commit 4494a5d

Please sign in to comment.