久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

python - 關(guān)于Scrapy中TwistedPipline報(bào)錯(cuò)

瀏覽:125日期:2022-07-10 08:23:55

問(wèn)題描述

> python3.5 / pycharm

crawlspider 返回的 item 是絕對(duì)沒有問(wèn)題的,接上TwistedPipline就報(bào)錯(cuò) 請(qǐng)哪位老師幫忙分析下報(bào)錯(cuò)代碼

# TwistedPiplineclass MysqlTwistedPipline(object): def __init__(self, dbpool):self.dbpool = dbpool @classmethod def from_settings(cls, settings):dbparms = dict( host = settings['MYSQL_HOST'], db = settings['MYSQL_DBNAME'], user = settings['MYSQL_USER'], passwd = settings['MYSQL_PASSWORD'], charset=’utf8’, cursorclass=MySQLdb.cursors.DictCursor, use_unicode=True,)dbpool = adbapi.ConnectionPool('MySQLdb', **dbparms)return cls(dbpool) def process_item(self, item, spider):query = self.dbpool.runInteraction(self.do_insert, item)query.addErrback(self.handle_error, item, spider) def handle_error(self, failure, item, spider):print (failure) def do_insert(self, cursor, item):insert_sql, params = item.insert_values()print (insert_sql, params)cursor.execute(insert_sql, params)return item

Error code

2017-05-01 00:06:16 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://www.lagou.com/jobs/2108656.html> (referer: https://www.lagou.com/zhaopin/Python/)2017-05-01 00:06:16 [scrapy.core.scraper] DEBUG: Scraped from <200 https://www.lagou.com/jobs/2108656.html>None[Failure instance: Traceback: <class ’TypeError’>: connect() argument 3 must be str, not NoneD:Python35libthreading.py:914:_bootstrap_innerD:Python35libthreading.py:862:runD:Python35libsite-packagestwisted_threads_threadworker.py:46:workD:Python35libsite-packagestwisted_threads_team.py:190:doWork--- <exception caught here> ---D:Python35libsite-packagestwistedpythonthreadpool.py:250:inContextD:Python35libsite-packagestwistedpythonthreadpool.py:266:<lambda>D:Python35libsite-packagestwistedpythoncontext.py:122:callWithContextD:Python35libsite-packagestwistedpythoncontext.py:85:callWithContextD:Python35libsite-packagestwistedenterpriseadbapi.py:464:_runInteractionD:Python35libsite-packagestwistedenterpriseadbapi.py:36:__init__D:Python35libsite-packagestwistedenterpriseadbapi.py:76:reconnectD:Python35libsite-packagestwistedenterpriseadbapi.py:431:connectD:Python35libsite-packagesMySQLdb__init__.py:86:ConnectD:Python35libsite-packagesMySQLdbconnections.py:204:__init__]

問(wèn)題解答

回答1:

從提示看出,你的配置(settings)的時(shí)候有1個(gè)參數(shù)是None,而不是字符串

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 新乡市| 万州区| 大关县| 九龙城区| 汉沽区| 醴陵市| 克什克腾旗| 长乐市| 桃园县| 古田县| 东明县| 华池县| 青川县| 河南省| 承德市| 赤壁市| 墨江| 蓬安县| 莎车县| 杭锦旗| 唐海县| 松滋市| 五原县| 二连浩特市| 平果县| 乌鲁木齐市| 东港市| 恭城| 海城市| 城固县| 托克托县| 青龙| 白水县| 隆回县| 苏尼特右旗| 布尔津县| 绥芬河市| 肇庆市| 余姚市| 航空| 鄂州市|