我正在尝试改进这种用于搜索演员维基页面并拉出所有电影链接的方法。目前,我正在使用 nokogiri 解析页面和正则表达式来检索标题中带有单词“(电影)”的所有链接,但这仍然错过了我需要的大部分链接。有没有人建议检索更多相关链接?
def find_films_by_actor(doca, out = [])
puts "Entering find_films_by_actor with #{find_name_title(doca)}."
all_links = doca.search('//a[@href]')
all_links.each do |link|
link_info = link['href']
if link_info.include?("(film)") && !(link_info.include?("Category:") || link_info.include?("php"))
then out << link_info end
end
out.uniq.collect {|link| strip_out_name(link)}
end