X-Scripts

READY-MADE SOLUTIONS FOR YOUR BUSINESS

OUR CONTACTS:
Skype: igor_sev2
Email : order@x-scripts.com

Script XHE adding content to the site.

On our website you can already find a script that adds the automatic blogs Wordpress. But what if you have a normal website which uses basic html+css. Very easy to fill articles on the website via ftp.
Suppose the task is to take news from a given site and publish them on your site. First of all find website donor news subjects. And find the website in the Ukrainian language, in order to translate these news and publish. Don't forget to check maybe someone already translate, and we all still interesting unique content.
so we found this website. Next we write the parsing we need pages.
Before that, we have prepared templates, which we will create pages for your website. Let it be itself a news page, all news and home page of the site.
In the templates we specify the keys to replace, as shown below in example:

<html>
<head>
<title>{TITLE}</title>
<meta name="keywords" content="{KEYS}">
<meta name="description" content="news">

<?include("../../top.php");?>
<?include("../../mid.php");?>

<h5>{TITLE}</h5>
<br> 
{IMG}{BODY} 
<br><br>
<i><font size="2" color="#000000">materials:</font></i> {SITE}
<br><br><br>
<a href="../../index_news.php" class="url_caption">All news < /a> 
<br>
<?include("../../bottom.php");?>
</i>

Not hard to guess that {TITLE} is the name of the news or articles, {KEYS} are the keys (we get them from the title - take it whole or divide, replacing the spaces , ), {IMG} - insert the picture {BODY} - the article itself or the news, {SITE} is the source of the article or news you can use, but you can not.

The script settings:


// ////////// the script settings///////////////////

// ftp settings for your site
$ftp_server ="your site name without the ftp";
$ftp_user="ftp login";
$ftp_pass="ftp password";

// path to templates
$tmp_index="data/tmp_1.php";
$tmp_news="data/tmp_2.php";
$tmp_ind_news="data/tmp_3.php";
// folder with the results
$res_folder="res/";
// path to folder with pictures
$img_folder="C:\\XWeb\\Human Emulator\\My Scripts\\add_news\\data\\images\\" ;
// the full path to the folder containing the results to download by ftp 
$res_folder_full="C:\\XWeb\\Human Emulator\\My Scripts\\add_news\\res\\" ;
// the number of added news at a time generate randomly from 1 to 3
$cnt_news=rand(1,3);
// the counter for names of news
$founded_news=0;

This script will run on schedule every day without any of your involvement and adds the desired content to the site automatically. The first couple will have to keep an eye on him and eliminate mistakes and errors.
When everything will fall on the rails you only occasionally need to look if nothing was changed on the website the donor.
Script can easily be changed, you can add multiple donors. It is also possible, depending on the amount of news already to share the page with news on the pages 1,2,3, etc. The only limit is your imagination :)


here is an example of such a script:

<?php

$xhe_host ="127.0.0.1:7010";

// The following code is required to properly run XWeb Human Emulator
require("../../Templates/xweb_human_emulator.php");

// ////////// the script settings///////////////////

// ftp settings 
$ftp_server ="your site name without the ftp";
$ftp_user="ftp login";
$ftp_pass="ftp password";

// path to templates
$tmp_index="data/tmp_1.php";
$tmp_news="data/tmp_2.php";
$tmp_ind_news="data/tmp_3.php";
// folder with the results
$res_folder="res/";
// path to folder with pictures
$img_folder="C:\\XWeb\\Human Emulator\\My Scripts\\add_news\\data\\images\\" ;
// the full path to the folder with the results
$res_folder_full="C:\\XWeb\\Human Emulator\\My Scripts\\add_news\\res\\" ;
// the number of added news
$cnt_news=rand(1,3);
// the counter news
$founded_news=0;

// debug mode
$dbg=true;
// /////////////////// additional modules /////////////////////
// class ftp 
include "ftp.php";
// function 
require_once("functions.php");

// ///////////////////// script /////////////////////////////////////////////////////////

debug_mess(date("\[ d.m.y H:i:s\] ")." script started");
// current date
$str_date=date("d.m.Y ");//"30.08.2012 ";//
// go to the site
$browser->navigate("website donor news");

$news=$webpage->get_body_inter_prefix_all("<table class=\"contentpaneopen\">","</table>");
$a_news=explode("<br>",$news);
for($i=0;$i<count($a_news)-1;$i++)
{
// check date news 
if(based($a_news[$i+1],$str_date))
{
$founded_news++;
debug_mess("found news $founded_news website donor news");
$href_news=get_string($a_news[$i],"href=\"","\">");
// the name of the news
$title_news=$anchor->get_inner_text_by_href($href_news,false);
$anchor->click_by_href($href_news,false);

// get file name
$img_src=$image->get_attribute_by_src("/images/news/",false,"src");
$img_src=str_replace("/images/news/","",$img_src);
// alt pattern 
$img_alt=$image->get_attribute_by_src("/images/news/",false,"alt");
// save the picture
$image->screenshot_by_src($img_folder.$img_src,"/images/news/",false);

// parse the news
$bd = $webpage->get_body();
$bd = get_string($bd,"<img class=\"img\"","Anywhere -->");
$bd_news = get_string($bd,"</noindex>","<!-- START: Modules");

// translate
$title_news=translate($title_news);
$img_alt=translate($img_alt);
$bd_news=translate($bd_news);

// create a page for the site
create_pages($title_news,$bd_news,$img_src,$img_alt,"the website donor news");

if($founded_news>=$cnt_news)
break;
}
}

debug_mess(date("\[ d.m.y H:i:s\] ")." script finished<br>");

// restart to clean the memory
//$app->restart();

// Quit
$app->quit();
?>



The script is written in 20.09.2012 Human Emulator 4.4.19 Advanced. At the time of publication of the article 22.09.2012 script was working.

download the script
Number of downloads: 2958

<< Other scripts