修改TA抓取程序

hotfix/远程访问多媒体中心
cyc 6 years ago
parent cc504e733f
commit ba7cd477e5

@ -311,6 +311,7 @@ class Index extends CI_Controller {
$destination = $this->input->get_post('destination');
$html_num = $this->input->get_post('html_num');
$group_name = $this->input->get_post('group_name');
$guidename = $this->input->get_post('guidename');
//$url = 'https://www.tripadvisor.com/ShowUserReviews-g308272-d6222868-r599123490-Shanghai_Trippest_Mini_Group_Tours-Shanghai.html';
//$destination = 'tp_Beijing';
@ -323,6 +324,8 @@ class Index extends CI_Controller {
$detail_data = new stdClass();
$detail_data->destination = $destination;
$detail_data->group_name = $group_name;
$detail_data->links = $url;
$detail_data->guidename = $guidename;
//提取局部,不做整个页面的寻找元素,提升效率
$meta_inner = $html_object->find('.meta_inner');

@ -180,13 +180,14 @@ class Tripadvisor_Review_model extends CI_Model {
tr_visited_date,
tr_review_pics,
tr_gri_no,
tr_tgi_sn,
tr_links,
tr_guidename,
tr_datetime
)values(
?,?,?,?,?,?,?,?,?,?,?,?,GETDATE()
)
?,?,?,?,?,?,?,?,?,?,?,?,?,GETDATE()
)
";
$query = $this->INFO->query($sql, array($detail_data->review_id,$detail_data->destination,$detail_data->review_id,$detail_data->title,$detail_data->content,$detail_data->review_name,$detail_data->user_loc,$detail_data->star_nums,$detail_data->rating_date,$detail_data->experience_date,json_encode($detail_data->pic),$detail_data->group_name,''));
$query = $this->INFO->query($sql, array($detail_data->review_id,$detail_data->destination,$detail_data->review_id,$detail_data->title,$detail_data->content,$detail_data->review_name,$detail_data->user_loc,$detail_data->star_nums,$detail_data->rating_date,$detail_data->experience_date,json_encode($detail_data->pic),$detail_data->group_name,$detail_data->links,$detail_data->guidename));
//$result = $query->result();
}

@ -181,7 +181,7 @@ $(function(){
}
});
//上传文件
//excel导出抓取
$('#contentbyexcel').click(function(){
var fileArray = document.getElementById("file_excel").files;
var formData = new FormData();
@ -208,20 +208,42 @@ $(function(){
html += '<p>'+jsondata[i].list_data[j][0]+'</p>';
html += '<p>团名:'+jsondata[i].list_data[j][1]+'</p>';
html += '<p>导游:'+jsondata[i].list_data[j][2]+'</p>';
html += '<p id="reviews_user_'+num+'"></p>';
html += '<p id="reviews_loc_'+num+'"></p>';
html += '<p id="reviews_stars_'+num+'"></p>';
html += '</div>';
html += '<div class="col-md-20">';
html += '<p id="excel_title_'+num+'"></p>';
html += '<p id="excel_reviewed_'+num+'"></p>';
html += '<p id="excel_content_'+num+'"></p>';
html += '<p id="excel_pic_'+num+'"></p>';
html += '<p id="excel_vistiedtime_'+num+'"></p>';
ta_url = jsondata[i].list_data[j][3];
//console.log(ta_url);
if(ta_url.indexOf('ShowUserReviews') != -1){
$.ajax({
url:'/info.php/apps/tripadvisor_spider/index/get_reviews_detail',
data:{url:ta_url,html_num:num,destination:jsondata[i].list_data[j][0],group_name:jsondata[i].list_data[j][1]},
data:{url:ta_url,html_num:num,destination:jsondata[i].list_data[j][0],group_name:jsondata[i].list_data[j][1],guidename:jsondata[i].list_data[j][2]},
success:function(json_detail,status){
var data = $.parseJSON(json_detail);
$('#excel_title_'+data.html_id).html(data.title);
$('#excel_content_'+data.html_id).html(data.content);
$('#reviews_user_'+data.html_id).html('评论用户:'+data.review_name);
$('#reviews_loc_'+data.html_id).html('评论用户地区:'+data.user_loc);
$('#excel_reviewed_'+data.html_id).html('Reviewed:'+data.rating_date);
$('#excel_vistiedtime_'+data.html_id).html('Date of experience:'+data.experience_date);
var stars_html = '';
for(var i=0;i<data.star_nums;i++){
stars_html += '<span class="glyphicon glyphicon-star"></span>';
}
$('#reviews_stars_'+data.html_id).html('星级:'+stars_html);
if($.parseJSON(data.pic).length > 0){
var pic_html = '';
for(var j=0;j<$.parseJSON(data.pic).length;j++){
pic_html += '<p><a href="'+$.parseJSON(data.pic)[j]+'" target="_blank"><img src="'+$.parseJSON(data.pic)[j]+'"/></a></p>';
}
}
$('#excel_pic_'+data.html_id).html(pic_html);
console.log(html);
}
});

Loading…
Cancel
Save