国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

python - 關于Scrapy中TwistedPipline報錯

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

問題描述

> python3.5 / pycharm

crawlspider 返回的 item 是絕對沒有問題的,接上TwistedPipline就報錯 請哪位老師幫忙分析下報錯代碼

# 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__]

問題解答

回答1:

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

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 绍兴市| 永兴县| 高淳县| 周至县| 洛川县| 福贡县| 商丘市| 新化县| 海南省| 芮城县| 钦州市| 高淳县| 大理市| 轮台县| 嘉祥县| 岚皋县| 万盛区| 兴业县| 桂东县| 新沂市| 肥东县| 开平市| 太仆寺旗| 屯留县| 东平县| 连南| 灌阳县| 独山县| 周口市| 五寨县| 吉隆县| 东乡族自治县| 石狮市| 济阳县| 兴城市| 拜城县| 乾安县| 常山县| 博野县| 海安县| 上蔡县|