文章采集发布(网站模板数据+3996条脚本代码(jq+css网页特效))
优采云 发布时间: 2021-11-10 14:02文章采集发布(网站模板数据+3996条脚本代码(jq+css网页特效))
日前,阿福发布了《模板屋静态模板免费下载》。后来阿福发现模板屋里的很多资源和站长素材的网页模板模块内容基本一致。
我们不知道谁背着谁,但站长素材不需要会员,即使不登录也可以下载!!!甘
马上阿福去爬取了一些数据,一共4799个网页模板数据+3996个脚本代码(jq+css网页特效)数据
我建立了一个测试站并对其进行了测试。wordpress发布正常,资源信息放在文章底部。请详细阅读操作流程,避免垃圾数据影响数据库使用。
成果展示:网站模板jquery
先看结果
第一步,将云盘中的两个sql文件导入到数据库中。数据库内容为采集站长资源获取的图片、说明、预览地址和下载地址
第二步,上传解压网站文件目录下的云盘关键图片资源,用于文章图片展示
共有 9792 张图片。下载图片的代码这里就不放了。阿福没有在站长资源中下载网页模板和脚本代码模块的所有数据采集。很多旧数据今天都过时了,所以只有采集前200页数据
第三步,在网站的根目录下创建任意php文件,添加如下代码
注:以下代码需要修改,如表名、每次插入的项数、文章内容修改等,这里阿福只提供一个简单的demo。思路是对表中的数据进行处理,批量插入到数据库中。
没有基本编码知识的同学可以联系阿福付费。此资源需要10福币,在本站登录两天内可免费兑换。
ini_set("display_errors", "stderr");
ini_set('max_execution_time', 3600);
error_reporting(E_ALL);
require __DIR__ . '/wp-config.php';
global $wpdb;
date_default_timezone_set('PRC');
//倒序 0-100
$jquery = $wpdb->get_results("select * from fu_jiaoben ORDER BY id desc limit 0,200");
$i = 0;$data = array();
foreach ($jquery as $row){
$data[$i]['title'] = $row->title."「免费免登陆下载」";
$filename = basename(explode('"', strip_tags(strstr($row->pic,'http')))[0]);
$posts = ''.$row->text.'
福源码为你提供大量精品jquery特效,css3*敏*感*词*,网页特效代码,广告代码,flash特效,javascript特效,flash特效,脚本代码,js特效,文字特效等网页特效素材免费下载。上千种免费资源下载尽在福源码FUYM.CN。
点击下载 <a href="'.explode('"', strip_tags(strstr($row-downloadlink,'http')))[0].'" target="_blank" rel="noopener"本地下载/a
在线预览 '.$row-preview.'
img class="alignnone size-full wp-image-542" src="http://www.fuym.cn/wp-content/uploads/jquery/'.$filename.'" //blockquote';
$data[$i]['posts'] = $posts;
$i++;
}
$post_tag_arr = array();
//先检查文章分类是否存在
$term_taxonomy_id = $wpdb-get_row("SELECT tt.term_taxonomy_id from $wpdb->terms t join $wpdb->term_taxonomy tt on t.term_id = tt.term_id where t.name = 'jQuery' and tt.taxonomy = 'category' ")->term_taxonomy_id;
if(!$term_taxonomy_id){
$wpdb->query("insert into $wpdb->terms (name,slug,term_group)VALUES('jQuery','jQuery','0')");
$category_id = $wpdb->insert_id;
$wpdb->query("insert into $wpdb->term_taxonomy (term_id,taxonomy,description,parent,count)VALUES($category_id,'category','','0','1')");
$term_taxonomy_id = $wpdb->insert_id;
}
$post_tag_arr[] = $term_taxonomy_id;
//检查文章标签是否存在 key=name value=slug
$terms_arr = array(
"网页特效" => "wytx",
"jQuery特效" => "jqtx",
"CSS特效" => "csstx",
"JavaScript特效" => "jstx",
"css *敏*感*词*" => "cssdh"
);
foreach ($terms_arr as $key => $value){
$term_taxonomy_id = $wpdb->get_row("SELECT tt.term_taxonomy_id from $wpdb->terms t join $wpdb->term_taxonomy tt on t.term_id = tt.term_id where t.name = '$key' and tt.taxonomy = 'post_tag' ")->term_taxonomy_id;
if(!$term_taxonomy_id){
$wpdb->query("insert into $wpdb->terms (name,slug,term_group)VALUES('$key','$value','0')");
$post_tag = $wpdb->insert_id;
$wpdb->query("insert into $wpdb->term_taxonomy (term_id,taxonomy,description,parent,count)VALUES($post_tag,'post_tag','','0','1')");
$term_taxonomy_id = $wpdb->insert_id;
}
$post_tag_arr[] = $term_taxonomy_id;
}
//检查文章专题是否存在
$term_taxonomy_id = $wpdb->get_row("SELECT tt.term_taxonomy_id from $wpdb->terms t join $wpdb->term_taxonomy tt on t.term_id = tt.term_id where t.name = 'jQuery' and tt.taxonomy = 'series' ")->term_taxonomy_id;
if(!$term_taxonomy_id){
$wpdb->query("insert into $wpdb->terms (name,slug,term_group)VALUES('jQuery','jQuery','0')");
$series_id = $wpdb->insert_id;
$wpdb->query("insert into $wpdb->term_taxonomy (term_id,taxonomy,description,parent,count)VALUES($series_id,'series','','0','1')");
$term_taxonomy_id = $wpdb->insert_id;
}
$post_tag_arr[] = $term_taxonomy_id;
foreach ($data as $value){
$posts = $wpdb->get_row("SELECT id from $wpdb->posts where post_title = '".$value['title']."' ");
if(!$posts){
$now = current_time( 'mysql' );
$now_gmt = current_time( 'mysql', 1 );
$wpdb->insert(
$wpdb->posts,
array(
'post_author' => 1,
'post_date' => $now,
'post_date_gmt' => $now_gmt,
'post_content' => $value['posts'],
'post_title' => $value['title'],
'post_excerpt' => '',
'post_status' => 'publish',
'comment_status' => 'open',
'ping_status' => 'open',
'post_password' => '',
'post_name' => $value['title'],
'to_ping' => '',
'pinged' => '',
'post_modified' => $now,
'post_modified_gmt' => $now_gmt,
'post_content_filtered' => '',
'post_parent' => '0',
'guid' => '',//文章链接 插入后修改
'menu_order' => '0',
'post_type' => 'post',
'post_mime_type' => '',
'comment_count' => '0',
)
);
echo($value['title']." 已写入数据库
");
$insertid = $wpdb->insert_id;
$post_guid = get_option( 'home' ) . '/?p='.$insertid;
$wpdb->query(" UPDATE $wpdb->posts SET guid=$post_guid where id = $insertid ");
//插入文章和分类、标签、专题的关系
$sql = " INSERT INTO $wpdb->term_relationships (object_id,term_taxonomy_id,term_order) VALUES ";
foreach ($post_tag_arr as $key => $value){
$sql .= "($insertid, $value, '0'),";
}
$wpdb->query(rtrim($sql, ","));
}
}
隐藏内容
这里的内容需要权限才能查看
登录后购买
免责声明:本站所有文章,除非另有说明或标注,均在本站原创上发布。任何个人或组织,未经本站同意,不得复制、盗用、采集、将本站内容发布到网站、书籍等任何媒体平台。本站侵犯原作者合法权益的,您可以联系我们进行处理。
阿福将军
支付宝扫一扫
微信扫一扫>打赏采集海报链接