我正在抓取物品并在網址中使用郵政編碼(cp)def parse(self, response): liste = ['09', '81'] for counter in range(len(liste)): cp = liste[counter] for i in range(0, 2): user_agent = random.choices(user_agent_list) headers = { 'User-Agent': str(user_agent), "Connection": "close", } next_pagination_link ='https://www.seloger.com/list.htm?projects=2&types=1,2&places=[{cp:' + str(cp) + '}]&sort=d_dt_crea&enterprise=0&qsVersion=1.0&LISTING- LISTpg=' + str(i) + ''在 pipilines.py 中,我在 process_item 方法中使用此腳本來刪除 sql 數據庫中的現有項目: if record is None: print('storing item') self.store_db(item) return True elif record is not None: raise DropItem("Item already exists: %s" % item['lien_du_bien'])我想要做的是:如果一個項目被丟棄,我想將蜘蛛中的變量計數器增加 1,以便移動到另一個郵政編碼。有沒有辦法做到這一點 ?
如果管道中的條件為 True ,如何在蜘蛛中增加計數器?[SCRAPY-Python]
慕碼人2483693
2022-10-18 15:57:35