
1 jason52 2013-05-23 16:08:00 +08:00 您是想抓图?哪里有ubb呢? |
2 jason52 2013-05-23 16:09:12 +08:00 you mean URL? |
3 KotiyaSanae 2013-05-23 16:31:48 +08:00 ```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[/ul] [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-05-23 16:53:07 +08:00 |
5 dreampuf 2013-05-23 16:53:21 +08:00 import re re.search("\\[(?:([^=]+)=([^\\]]+)|([^\\]]+))\\]([^\\[]+)\\[/(?:\\1|\\3)\\]", searchText) |
6 kenneth OP |
7 KotiyaSanae 2013-05-23 19:08:44 +08:00 @kenneth 没太看懂你要匹配什么,是所有的boston么?那个网站不太会用…… pattern = r'.*](http://.*html?).*' ? python环境下通过…… |
8 jason52 2013-05-23 23:08:17 +08:00 这种事强烈推荐用pyquery做 代码可以很简单 抓图代码就这么一点 http://dpaste.com/1196576/ |
9 jason52 2013-05-23 23:17:39 +08:00 @KotiyaSanae 如果用re的话这种可以 |