Automatic filling WordPress content
As promised, I spread a script for creating content for a blog on wordpress (on how to fill blogs on wordpress content I wrote in a note to add content automatically in WordPress-blogs ).
Go on Again "as is" - working there, but not guaranteed ostalnoe ![]()
By the way, on the basis of the script and was born a free program for creating imported into the WordPress XML-file - WordPress XML Creator .
#! / Usr / bin / perl-w # (c) dimio # http://www.dimio.org use strict; use DBI; # die "will not forget Convert input file to Unicode! NE ZABUD SKONVERTIROVAT VHODNOY FILE V UTF! "; my $ game_descr_file = 'game_descr.txt'; my $ db_type = 'SQLite'; my $ db_name = '.. / sqlite_db / gb_blogs.sqlite'; my $ db_login =''; my $ db_password =''; my $ dbh = db_connect ($ db_type, $ db_name, $ db_login, $ db_password); database_filling ($ game_descr_file, $ dbh); $ dbh-> disconnect; exit 0; sub database_filling {# Parse the source file with descriptions of games, titles and tags for them. # Each entry is broken down into, and updated the corresponding table in the database. my ($ infile, $ dbh) = @ _; my ($ GameID, $ PostHeader, $ PostBody, $ PostTags, $ file, $ BlogID); open (IN_FILE, '<', $ infile) or die "Can't open file $ infile: ". $!, "\ N"; {local $ / = "\ n \ n"; # locally within a block of {} by changing the sign of the end of the input string as individual texts in the file are separated by a blank line. while (<IN_FILE>) {+ + $ BlogID; chomp; s / ^ \ s + / /; s / \ s +$//; if (m! <game_id> (\ d +) </ game_id> \ n <header> (.+)</ header> \ n <body> (.+)</ body> \ n <tags> (.+)</ tags>! xsi) {($ GameID, $ PostHeader, $ PostBody, $ PostTags ) = ($ 1, $ 2, $ 3, $ 4); # print "GID: $ GameID \ nBLOG: $ BlogID \ nHEAD: $ PostHeader \ nBODY: $ PostBody \ nTAGS: $ PostTags \ n"; put_to_db ($ dbh, $ GameID , $ PostHeader, $ PostBody, $ PostTags, $ BlogID); # put the data into the database} else {die "Check input file format! (end of line (must be \ \ n - unix) or encoding (must be UTF- 8) \ n ";}}} close (IN_FILE);} sub db_connect {my ($ db_type, $ db_name, $ db_login, $ db_password) = @ _; my $ dbh = DBI-> connect (" DBI: $ db_type : $ db_name "," $ db_login "," $ db_password ", # {Unicode => 1}) or die" Connecting: $ DBI:: errstr \ n "; # connect to the database SQL (opens a database handle) $ dbh- > {unicode} = 1 if $ db_type eq 'SQLite'; return $ dbh} sub put_to_db {my ($ dbh, $ GameID, $ PostHeader, $ PostBody, $ PostTags, $ BlogID) = @ _; # my $ db_data = $ dbh-> do ("INSERT INTO BlogsMainData (BlogID) VALUES $ BlogID;"); my $ query = "UPDATE BlogsContent SET PostHeader = '$ PostHeader', PostBody = '$ PostBody', PostTags = '$ PostTags' WHERE GameID = $ GameID AND BlogID = $ BlogID AND PostHeader IS NULL; "; my $ db_data = $ dbh-> do ($ query); $ query> 0? print" $ GameID added \ n ": print" $ GameID not added \ n ";}
More on similar topics:
Filed under: SEO , Blogging , Gadgets , Coding |
Tags: perl , WordPress , blog , programming , satellite |
5 comments 

If you did all this plugin for wp, then prices would have been!
Oh, why. And because their functions are carried out.
Can and does, but to insert into your blog, this code I do not know where .. a blog on wordpress
This is a completely separate script, paste it to your blog is not necessary. It runs just like any other Perl script.
Thank you! Now he understood.