Javascript 余烬应用程序和谷歌爬虫
我正在尝试使我的余烬应用程序可爬行。据我所知,谷歌现在支持JS、CSS和AJAX(从2015年10月开始)。但当我通过“以谷歌身份获取”测试我的网站时,我会得到背景为空的页面: 当然,在现实中,我的内容和页面看起来完全不同:Javascript 余烬应用程序和谷歌爬虫,javascript,ajax,ember.js,web-crawler,google-crawlers,Javascript,Ajax,Ember.js,Web Crawler,Google Crawlers,我正在尝试使我的余烬应用程序可爬行。据我所知,谷歌现在支持JS、CSS和AJAX(从2015年10月开始)。但当我通过“以谷歌身份获取”测试我的网站时,我会得到背景为空的页面: 当然,在现实中,我的内容和页面看起来完全不同: 我做错了什么 您可以使用Ember Fastboot- 或者使用类似的服务 祝你好运 经过一天的调查,我发现了两个阻碍爬行的问题 1.输入验证组件 import Ember from 'ember'; const { computed, observer, d
我做错了什么 您可以使用Ember Fastboot- 或者使用类似的服务
祝你好运 经过一天的调查,我发现了两个阻碍爬行的问题 1.输入验证组件
import Ember from 'ember';
const {
computed,
observer,
defineProperty,
run
} = Ember;
export default Ember.Component.extend({
classNames: ['form-group', 'has-feedback', 'validated-input'],
classNameBindings: ['isValid:has-success', 'showErrorClass:has-error'],
isValid: false,
model: null,
value: null,
rawInputValue: null,
type: 'text',
valuePath: '',
placeholder: '',
attributeValidation: null,
isTyping: false,
didValidate: computed.oneWay('targetObject.didValidate'),
showErrorClass: computed('isTyping', 'showMessage', 'hasContent', 'attributeValidation', function() {
return this.get('attributeValidation') && !this.get('isTyping') && this.get('showMessage');
}),
hasContent: computed.notEmpty('rawInputValue'),
isValid: computed.and('hasContent', 'attributeValidation.isValid'),
isInvalid: computed.oneWay('attributeValidation.isInvalid'),
inputValueChange: observer('rawInputValue', function() {
this.set('isTyping', true);
run.debounce(this, this.setValue, 500, false);
}),
showMessage: computed('attributeValidation.isDirty', 'isInvalid', 'didValidate', function() {
return (this.get('attributeValidation.isDirty') || this.get('didValidate')) && this.get('isInvalid');
}),
setValue() {
this.set('value', this.get('rawInputValue'));
this.set('isTyping', false);
},
init() {
this._super(...arguments);
var valuePath = this.get('valuePath');
defineProperty(this, 'attributeValidation', computed.oneWay(`model.validations.attrs.${valuePath}`));
this.set('rawInputValue', this.get(`model.${valuePath}`));
defineProperty(this, 'value', computed.alias(`model.${valuePath}`));
}
});
我用新的替换了这个组件
2.这段代码(我写它是为了性能优化):
我修复了这两个问题,现在google bot能够呈现我的应用程序。不幸的是,由于环境限制,我无法使用FastBoot。实际上,我已经看过为爬虫提供服务器渲染的不同在线服务,但突然我看到了这一点:。所以我得出结论,谷歌爬虫可能会索引我的应用程序。
ingredients: function() {
var self = this;
return DS.PromiseArray.create({
promise: new Promise((resolve, reject) => {
let loadedIngredients = self.store.peekAll('ingredient');
if (loadedIngredients && loadedIngredients.get('length') > 0) {
let mappedIngredients = self.get('recipe').get('ingredientsWithQuantities').map(function(item) {
return {
name: self.store.peekRecord('ingredient', item.ingredientId).get('name'),
quantity: item.quantity
};
});
resolve(mappedIngredients);
} else {
this.store.findAll('ingredient').then(function() {
let mappedIngredients = self.get('recipe').get('ingredientsWithQuantities').map(function(item) {
return {
name: self.store.peekRecord('ingredient', item.ingredientId).get('name'),
quantity: item.quantity
};
});
resolve(mappedIngredients);
})
}
})
});
}.property('recipe.ingredientsWithQuantities')