@@ -94,26 +94,18 @@ func (self ArticleLogic) ParseArticle(ctx context.Context, articleUrl string, au
94
94
return nil , err
95
95
}
96
96
97
- author , authorTxt := "" , ""
97
+ author := ""
98
98
if rule .InUrl {
99
99
index , err := strconv .Atoi (rule .Author )
100
100
if err != nil {
101
101
logger .Errorln ("author rule is illegal:" , rule .Author , "error:" , err )
102
102
return nil , err
103
103
}
104
104
author = urlPaths [index ]
105
- authorTxt = author
106
105
} else {
107
- if strings .HasPrefix (rule .Author , "." ) || strings .HasPrefix (rule .Author , "#" ) {
108
- authorSelection := doc .Find (rule .Author )
109
- author , err = authorSelection .Html ()
110
- if err != nil {
111
- logger .Errorln ("goquery parse author error:" , err )
112
- return nil , err
113
- }
114
-
115
- author = strings .TrimSpace (author )
116
- authorTxt = strings .TrimSpace (authorSelection .Text ())
106
+ authorSelection := doc .Find (rule .Author )
107
+ if authorSelection .Is (rule .Author ) {
108
+ author = strings .TrimSpace (authorSelection .Text ())
117
109
} else if strings .HasPrefix (rule .Author , "/" ) {
118
110
// 正则表达式
119
111
re , err := regexp .Compile (rule .Author [1 :])
@@ -129,11 +121,9 @@ func (self ArticleLogic) ParseArticle(ctx context.Context, articleUrl string, au
129
121
}
130
122
131
123
author = authorResult [1 ]
132
- authorTxt = author
133
124
} else {
134
125
// 某些个人博客,页面中没有作者的信息,因此,规则中 author 即为 作者
135
126
author = rule .Author
136
- authorTxt = rule .Author
137
127
}
138
128
}
139
129
@@ -222,7 +212,7 @@ func (self ArticleLogic) ParseArticle(ctx context.Context, articleUrl string, au
222
212
Domain : domain ,
223
213
Name : rule .Name ,
224
214
Author : author ,
225
- AuthorTxt : authorTxt ,
215
+ AuthorTxt : author ,
226
216
Title : title ,
227
217
Content : content ,
228
218
Txt : txt ,
@@ -870,7 +860,7 @@ func (self ArticleLogic) setImgSrc(ctx context.Context, v string, imgDeny bool,
870
860
if strings .HasPrefix (v , "//" ) {
871
861
v = "https:" + v
872
862
} else if ! strings .HasPrefix (v , "http" ) {
873
- v = "http://" + domain + "/" + v
863
+ v = "http://" + domain + v
874
864
}
875
865
path , err := DefaultUploader .TransferUrl (ctx , v )
876
866
if err == nil {
0 commit comments