0
나는 다음과 같은 코드가 있습니다출력을 여러 번
이- 코드는 한 번 세 번을 출력하지 :
require 'rubygems' require 'nokogiri' require 'open-uri' time = Time.new url = "http://mobile.bahn.de/bin/mobil/bhftafel.exe/dox?input=Richard-Strauss-Stra%DFe%2C+M%FCnchen%23625127&date=" + time.strftime("%d%m%Y") + "&time=" + time.strftime("%H") + "%3A" + time.strftime("%M") + "&productsFilter=1111111111000000&REQTrain_name=&maxJourneys=10&start=Suchen&boardType=Abfahrt&ao=yes" doc = Nokogiri::HTML(open(url)) doc.xpath('//div//p').remove doc.encoding = 'UTF-8' doc = doc.xpath('//div').each do |node| text = node.text.gsub(/\n([ \t]*\n)+/,"\n",).gsub(/^\s+|\s+$/,'').gsub("Startseite", '').gsub("Impressum", '') puts text unless text.empty? end
나는 두 가지 문제가 있습니다.
- 독일의 "움라우트"는
äü
입니다.