-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmistakes-solved
18 lines (18 loc) · 1.16 KB
/
mistakes-solved
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
1.[Failure instance: Traceback: <class 'KeyError'>: 'article_content'
#The reason is that the key value is wrong. Generally, the CSS selector cannot get the corresponding value on the page
#(for example, the page is changed to cause it is not a regular page).
#The value of the spider does not correspond to the item key.
#when i try to connect mysql,the mistake happened
#First I checked the match-status between elements and symbols
insert into article(read_count,article_content,article_author,article_title,article_pubTime,article_id,subjects,origin_url,article_avatar,
word_count,comment_count,like_count) values(%d,%s,%s,%s,%s,%s,%s,%s,%s,%d,%d,%d)
#And I found that the result is the crawled elelment "article_content" is a list object,so i transformed it to a string object by using join()
def connect_list_vector(self,contents):
if len(contents)>1:
str_article_content='.'.join(contents)
return str_article_content
else:
return contents
#Problem solved
2.[Failure instance: Traceback: <class 'pymysql.err.InternalError'>: (1054, "Unknown column 'like_count' in 'field list'")
#The database field is not the same as the item key