나는 angularjs 사이트를 크롤링 할 수 있도록 노력하고 있습니다. 그렇게하려면 Google에서 제안한대로? _escaped_fragment = solution을 사용하고 있습니다. 예를 들어angularjs : Ruby On Rails 크롤링을 사용하지 않는 Ajax 웹 사이트
:
구글"http://xample.com/#!/Home"
같은 해시 조각에 요청을보고
, 그것은 "http://xample.com/?_escaped_fragement_=/Home"
에 URL을 변환합니다.
나는 이러한 요청을 받아들이고 해당 요청을 crawler controller
으로 리디렉션하는 차례로 Index controller
을 구현했으며이 요청은 동적으로 생성 된 HTML 스냅 샷을 Google에 제공합니다.
는 그러나 나의 홈 페이지를 제외하고 http://xample.com/
다른 페이지를 크롤링하지 얻고있다 (아마도 때문에 hashbang의)
아래는 심지어 구글에 의해 제안 _escaped_fragment_ = 솔루션 구현 후 크롤되지 않은 URL은 다음과 같습니다 -.?을
저에서 사용http://xample.com/#!/Home
http://xample.com/#!/xyz
http://xample.com/#!/abc
http://xample.com/#!/def
컨트롤러 : - "? _escaped_fragment_ ="
Index controller
는
class IndexController < ApplicationController
def index()
if params['_escaped_fragment_'] == '/Home'
redirect_to :controller=>'crawler', :action => 'crawlhome'
return
elsif params['_escaped_fragment_'] == '/Xyz'
redirect_to :controller=>'crawler', :action => 'crawlxyz'
return
end
elsif params['_escaped_fragment_'] == '/abc'
redirect_to :controller=>'crawler', :action => 'crawlabc'
return
end
end
elsif params['_escaped_fragment_'] == '/def'
redirect_to :controller=>'crawler', :action => 'crawldef'
return
end
end
내 회사에서 일하는 서 관계자는 url.Is에서 (상태를 밀어) hashbang
없이이 최적의 솔루션을 웹 사이트를 구현하기 위해 나에게 제안
class CrawlerController < ApplicationController
layout false
require 'net/http'
require 'uri'
def crawlhome
@data = "getting data from api and displaying same data in view"
end
def crawlXyz
@data = "getting data from api and displaying same data in view"
end
def crawlabc
@data = "getting data from api and displaying same data in view"
end
def crawldef
@data = "getting data from api and displaying same data in view"
end
end
크롤러 컨트롤러 문제.
그러나 이것은 HTML이 아닌 브라우저에서는 작동하지 않습니다.
http://xample.com/#!/Home
을 구현하면 어떤 문제가 발생할 수 있습니다. 위의 경우 크롤링되지 않는 이유는 무엇입니까?
나는 많은 다른 해결책을 포럼에서 시도했지만 여전히 나에게 적절한 결과를주지 못했다.