开发者

List all links in a mySQL table, multiple links per row

I have a CMS. I'd like to get a list of all the links in all of the content.

If pages.content is my table.field, then I can get pages that have A link:

SELECT id, content FROM开发者_运维知识库 pages 
  WHERE lower(content) RLIKE '<a href="[^"]+">[^<]+</a>'

That's as far as I get before I get stumped, though. How to return only the link and handle multiple links in content?

I'll open this up to Ruby on Rails answers, too. I'm actually trying to search for links, matching on the link text. I thought getting all of the links straight from the db was the best way to do it, but I might have to resort to pulling a lot of the results and split()ing them in Ruby.


A better option would be to go for nokogiri to parse the content and extract the links. If your content is in HTML/XML format that is.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜