1
jason52 2013 年 5 月 23 日
您是想抓图?哪里有ubb呢?
|
2
jason52 2013 年 5 月 23 日
you mean URL?
|
3
KotiyaSanae 2013 年 5 月 23 日
```python
import re content=""" [URL="http://www.boston.com/bigpicture/2008/10/the_sun.html"]http://www.boston.com/bigpictu....html[/URL] [url="http://www.boston.com/bigpicture/2008/10/the_sun.html"]http://www.boston.com/bigpictu....html[/url] [URL=http://www.boston.com/bigpicture/2008/10/the_sun.html]http://www.boston.com/bigpictu....html[/URL] [url=http://www.boston.com/bigpicture/2008/10/the_sun.html]http://www.boston.com/bigpictu....html[/url] [url]http://www.boston.com/bigpictu....html[/url] [URL]http://www.boston.com/bigpictu....html[/URL] """ pattern = r'.*(http://.*html?).*' pat = re.compile(pattern) pat.findall(content) ``` |
4
dreampuf 2013 年 5 月 23 日 |
5
dreampuf 2013 年 5 月 23 日
import re
re.search("\\[(?:([^=]+)=([^\\]]+)|([^\\]]+))\\]([^\\[]+)\\[/(?:\\1|\\3)\\]", searchText) |
6
kenneth OP |
7
KotiyaSanae 2013 年 5 月 23 日
@kenneth 没太看懂你要匹配什么,是所有的boston么?那个网站不太会用……
pattern = r'.*](http://.*html?).*' ? python环境下通过…… |
8
jason52 2013 年 5 月 23 日
这种事强烈推荐用pyquery做 代码可以很简单 抓图代码就这么一点
http://dpaste.com/1196576/ |
9
jason52 2013 年 5 月 23 日
@KotiyaSanae 如果用re的话这种可以
|