Skip to content

Commit aae2127

Browse files
author
Boris
committed
修复item table name提取错误的bug
1 parent 1279e21 commit aae2127

5 files changed

Lines changed: 31 additions & 8 deletions

File tree

docs/question/安装问题.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 常见问题
1+
# 安装问题
22

33
## 1. window下pip 安装报错
44

docs/question/运行问题.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 运行问题
2+
3+
## 1. 二次运行时卡住,不继续抓取
4+
5+
![1779423237](media/1779423237.jpg)
6+
7+
原因:因爬虫支持分布式,qu
8+
9+

feapder/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.0
1+
1.2.1

feapder/utils/tools.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,8 +1970,20 @@ def make_batch_sql(
19701970
############### json相关 #######################
19711971

19721972

1973-
def key2underline(key):
1974-
regex = "[A-Z]*"
1973+
def key2underline(key, strict=True):
1974+
"""
1975+
>>> key2underline("HelloWord")
1976+
'hello_word'
1977+
>>> key2underline("SHData", strict=True)
1978+
's_h_data'
1979+
>>> key2underline("SHData", strict=False)
1980+
'sh_data'
1981+
>>> key2underline("SHDataHi", strict=False)
1982+
'sh_data_hi'
1983+
>>> key2underline("SHDataHi", strict=True)
1984+
's_h_data_hi'
1985+
"""
1986+
regex = "[A-Z]*" if not strict else "[A-Z]"
19751987
capitals = re.findall(regex, key)
19761988

19771989
if capitals:
@@ -1980,7 +1992,9 @@ def key2underline(key):
19801992
continue
19811993
if pos == 0:
19821994
if len(capital) > 1:
1983-
key = key.replace(capital, capital.lower() + "_", 1)
1995+
key = key.replace(
1996+
capital, capital[:-1].lower() + "_" + capital[-1].lower(), 1
1997+
)
19841998
else:
19851999
key = key.replace(capital, capital.lower(), 1)
19862000
else:

tests/spider/items/spider_data_item.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""
3-
Created on 2021-02-08 16:40:12
3+
Created on 2021-03-10 17:28:36
44
---------
55
@summary:
66
---------
@@ -17,5 +17,5 @@ class SpiderDataItem(Item):
1717
"""
1818

1919
def __init__(self, *args, **kwargs):
20-
# self.id = None # type : int(10) unsigned | allow_null : NO | key : PRI | default_value : None | extra : auto_increment | column_comment :
21-
self.title = None # type : varchar(255) | allow_null : YES | key : | default_value : None | extra : | column_comment :
20+
# self.id = None
21+
self.title = None

0 commit comments

Comments
 (0)