if response.xpath('//link[contains(@rel,"apple-touch-icon-precomposed")]/@href') :
apple_touch_url = response.xpath('//link[contains(@rel,"apple-touch-icon-precomposed")]/@href').extract()
apple_touch_url=[link for link in apple_touch_url if 'https' in link or 'http' in link ]
item['logo'] = apple_touch_url
if not apple_touch_url:
‘这里没有这个列表我想走 elif 的逻辑’但是好像没有这样的语法,求人指教,谢谢
elif response.xpath('//link[contains(@rel,"icon")]/@href'):
rel_url=response.xpath('//link[contains(@rel,"icon")]/@href').extract()
item['logo']=rel_url
print(rel_url)
apple_touch_url = response.xpath('//link[contains(@rel,"apple-touch-icon-precomposed")]/@href').extract()
apple_touch_url=[link for link in apple_touch_url if 'https' in link or 'http' in link ]
item['logo'] = apple_touch_url
if not apple_touch_url:
‘这里没有这个列表我想走 elif 的逻辑’但是好像没有这样的语法,求人指教,谢谢
elif response.xpath('//link[contains(@rel,"icon")]/@href'):
rel_url=response.xpath('//link[contains(@rel,"icon")]/@href').extract()
item['logo']=rel_url
print(rel_url)