the articles are in your wordpress sql database. if you want, you can export the database to get the content, or just code a simple php script to output the wordpress arrticles as you needI want to export the articles on my website to .txt but I can't find a plugin for this. Every export plugin allow you to export in csv and other formats but not txt.
Any idea what should I do?
I don't need categories and such, I only need to store the title (possibly as the name of the file) and the content of the article. If html is stored is even better since I will throw those articles on RankerX, so those articles will be published on 2.0s and similar.And what kind of format do you expect your txt file to be in? How do you store tags, categories, author, date times, and other meta data associated with each post?
What is it exactly you are trying to save to txt? WP converts the content in the editor to html so even if you export just the content in each page you will still end up with html. Pandoc will allow you to convert this markup to any other markup.
You could use the WP rest API, example.com/wp-json/wp/v2/posts to fetch your WP content as a JSON object, then iterate the results, and save the post content to the post-slug-as-the-filename.txt as the filename.
I don't need categories and such, I only need to store the title (possibly as the name of the file) and the content of the article. If html is stored is even better since I will throw those articles on RankerX, so those articles will be published on 2.0s and similar.
<?php
/* quick example script to save (or print) all titles + posts from wordpress
* (C) styx @ argo-content.com
*/
define('USER', 'wpusr'); // mysql user
define('PASS', 'wppass'); // mysql pass
define('DB', 'wpdb'); // database name
define('DBHOST', 'localhost'); // database host
define('SFX', 'wp'); // WP db suffix ('wp' by default)
function connect_db() {
$mysql = new mysqli(DBHOST,USER,PASS,DB);
if(mysqli_connect_errno()) {
printf("Error - database connection failed: %s", mysqli_connect_error());
die();
}
return $mysql;
}
function static_query($query, $mysql) {
if(!$st=$mysql->query($query)) {
die('error: '.$mysql->error."\n");
}
return $st;
}
function get_posts($mysql) {
$rw=NULL;
$st = static_query('SELECT post_title,post_content FROM '.SFX.'_posts', $mysql);
while($rw=$st->fetch_assoc()) {
$arr[] = array($rw['post_title'], strip_tags($rw['post_content']));
}
return $arr;
}
$mysql = connect_db();
$posts = get_posts($mysql);
foreach ($posts as $p) {
// print('title: '.$p[0]."\n".'post: '.$p[1]."\n --- \n");
$fl = str_replace(' ', '-', $p[0]).'.txt';
file_put_contents($fl, $p[1]);
}
?>
THANK YOU VERY MUCH!!!!here is a simple example that i just made to save/print all titles + posts from wp.
just modify it for your needs
Code:<?php /* quick example script to save (or print) all titles + posts from wordpress * (C) styx @ argo-content.com */ define('USER', 'wpusr'); // mysql user define('PASS', 'wppass'); // mysql pass define('DB', 'wpdb'); // database name define('DBHOST', 'localhost'); // database host define('SFX', 'wp'); // WP db suffix ('wp' by default) function connect_db() { $mysql = new mysqli(DBHOST,USER,PASS,DB); if(mysqli_connect_errno()) { printf("Error - database connection failed: %s", mysqli_connect_error()); die(); } return $mysql; } function static_query($query, $mysql) { if(!$st=$mysql->query($query)) { die('error: '.$mysql->error."\n"); } return $st; } function get_posts($mysql) { $rw=NULL; $st = static_query('SELECT post_title,post_content FROM '.SFX.'_posts', $mysql); while($rw=$st->fetch_assoc()) { $arr[] = array($rw['post_title'], strip_tags($rw['post_content'])); } return $arr; } $mysql = connect_db(); $posts = get_posts($mysql); foreach ($posts as $p) { // print('title: '.$p[0]."\n".'post: '.$p[1]."\n --- \n"); $fl = str_replace(' ', '-', $p[0]).'.txt'; file_put_contents($fl, $p[1]); } ?>
no problem, glad i could helpTHANK YOU VERY MUCH!!!!
here is a simple example that i just made to save/print all titles + posts from wp.
just modify it for your needs
Code:<?php /* quick example script to save (or print) all titles + posts from wordpress * (C) styx @ argo-content.com */ define('USER', 'wpusr'); // mysql user define('PASS', 'wppass'); // mysql pass define('DB', 'wpdb'); // database name define('DBHOST', 'localhost'); // database host define('SFX', 'wp'); // WP db suffix ('wp' by default) function connect_db() { $mysql = new mysqli(DBHOST,USER,PASS,DB); if(mysqli_connect_errno()) { printf("Error - database connection failed: %s", mysqli_connect_error()); die(); } return $mysql; } function static_query($query, $mysql) { if(!$st=$mysql->query($query)) { die('error: '.$mysql->error."\n"); } return $st; } function get_posts($mysql) { $rw=NULL; $st = static_query('SELECT post_title,post_content FROM '.SFX.'_posts', $mysql); while($rw=$st->fetch_assoc()) { $arr[] = array($rw['post_title'], strip_tags($rw['post_content'])); } return $arr; } $mysql = connect_db(); $posts = get_posts($mysql); foreach ($posts as $p) { // print('title: '.$p[0]."\n".'post: '.$p[1]."\n --- \n"); $fl = str_replace(' ', '-', $p[0]).'.txt'; file_put_contents($fl, $p[1]); } ?>
thanks, however this is not something scrapebox can do. I mean your talking about exporting off your website.scrapebox may be able to do this
@loopline may know the answer
save it as file i.e. export.php, then run it in the shell like: php export.phpSry but how to use this lol
It's a simple process, install an Aspose DOC Exporter. create a free account with aspose cloud and get an app id and key.once you sign up you can begin with export.I want to export the articles on my website to .txt but I can't find a plugin for this. Every export plugin allow you to export in csv and other formats but not txt.
Any idea what should I do?