spider
分享
_leven
这个作者很懒,什么都没留下…
展开
-
scrapy架构中CrawlSpider全站爬取中,Rule的顺序也分先后
rules = ( Rule(link, callback='parse_item', follow=False), Rule(link_detail, callback='detail_url') )如果将代码块中的Rule的位置先后对调,结果就会不同,并且元组的最后是没有逗号的,当只有一个匹配re时需要加逗号!...原创 2021-08-06 14:55:09 · 252 阅读 · 0 评论 -
Not all parameters were used in the SQL statement
#错误示例: try: insert_sql = 'insert into mydb(url, title_)' insert_value = (item['detail_urls'], item['title']) self.cursor.execute(insert_sql, insert_value) self.mydb.commit() except Excepti..原创 2021-08-05 23:32:09 · 227 阅读 · 0 评论 -
object is not subscriptable‘ 在python中遇到这种错误
# 错误演示:item 和 spider 参数位置错误: def process_item(self, spider,item,): self.cursor = self.connect.cursor()# 正确演示: def process_item(self, item, spider): self.cursor = self.connect.cursor()这个错误排了一个多小时,其中还有一些粗心的小错误。还是要仔细啊!...原创 2021-08-05 00:30:41 · 1191 阅读 · 0 评论 -
KeyError(f“{self.__class__.__name__} does not support field: {key}“)
在python中遇到此类的错误提示: raise KeyError(f"{self.__class__.__name__} does not support field: {key}")解决办法:根据scrapy架构item源码的代码来分析: def __setitem__(self, key, value): if key in self.fields: self._values[key] = value else:原创 2021-08-04 22:34:07 · 1143 阅读 · 0 评论