pipelines.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:byrbbs-py3 作者: ryderchan 项目源码 文件源码
def process_item(self, item, spider):
        con = pymysql.connect(**DB_CONFIG)
        cur = con.cursor()
        sql = 'replace into articleinfohour(section_url,article_title,' \
              'article_url,article_comment,article_author,article_createtime,updatetime) ' \
              'values(%s,%s,%s,%s,%s,%s,%s)'
        values = (item['section_url'], item['article_title'], item['article_url'], item['article_comment'],
                  item['article_author'], item['article_createtime'], item['updatetime'])
        cur.execute(sql, values)  # second parameter must be iterabale
        con.commit()
        cur.close()
        con.close()
        return item
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号