简体   繁体   中英

Exclude more than one condition with regex Scrapy

I´m new with Scrapy

I want to exclude two elements in the same item. Below I´m excluding "SKU:", I wanna add " sku ". I didn´t find the way.

'SKU': ready.xpath(SKU).re_first(r'SKU:\s*(.*)'), # Limpia SKU:

Anny suggestion? thanks so much

Not sure what exactly you want, but looks like you talk about regex that can run against both "SKU" and "sku". In extract_first you can use python compiled regular expression rather than string, so it could be done like this:

import re

re_sku = re.compile(r'sku:*\s*(.+)', re.IGNORECASE)

...
'SKU': ready.xpath(SKU).re_first(re_sku),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM