【发布时间】:2015-12-11 04:48:16
【问题描述】:
这是我的正则表达式:
".*\/(.*)\?ref"
这是我的测试字符串:
/product/sam/go-with-me?ref=popular
我可以得到:go-with-me
我确实尝试过https://regex101.com/#python
但是我不知道怎么用scrapy写, 它什么也得不到
这是我的代码:
for site in sites:
title = sel.css("a::text").re(r".*\/(.*)\?ref")
print title
break
【问题讨论】:
-
你能分享一个包含所需链接的示例 HTML 代码吗? (或分享网页的网址)
标签: python regex web-scraping scrapy