Jump to content

Kiddnapped Weblog


Wolfsoap

Recommended Posts

Hay, I've been looking hard and can't find anything that does this, its pretty strange too. It seems like something that would be commonly used.

 

I want to back up my Blogger blog to a mysql database so i can move all of my posts over to my new site which isn't blogger hosted, but I cant find any way to save all the blogger post to a database.

 

Can anyone help, can anyone save me from the peril of copy and pasting 100's of old blog entires into a new database?

Link to comment
Share on other sites

I'm working on it.

 

here's what I have so far. its ugly.

$capture=file_get_contents ('http://resago.blogspot.com');
preg_match('/<div class=\'main section\' id=\'main\'>(.+)<div id=\'sidebar-wrapper\'>/s', $capture, $info);
#print_r ($info);
$posts="$info[1]";
$posts_array=preg_split('/<a name=\'\d+\'><\/a>/',$posts);
#array_shift($posts_array);
$posts_array=str_replace('<br />',"\n",$posts_array);
$posts_array=preg_replace("/(<\/?)(\w+)([^>]*>)/","",$posts_array);
$posts_array=preg_replace("/\n+/","\n",$posts_array);
print "<hr><pre>";
print_r($posts_array);

 

Link to comment
Share on other sites

this writes out a text file where each line is a separate post.

manipulate in excel however you want, then use simple import.

 

<?php
#Look at your blog html code and figure out the following:
#These default settings work for the simple blue template on blogspot
$blogurl="http://YOU.blogspot.com";#url
$begin="<div class=\'main section\' id=\'main\'>";#some unique text to specify starting point
$end="<div id=\'sidebar-wrapper\'>";#some unique text to specify ending point
$sep="<div class=\'post hentry\'>";#some unique text to specify post separation
$keepimages="yes";#change if you don't care about image url

#################################################################################
$capture=file_get_contents ($blogurl);
preg_match("/$begin(.+)$end/s", $capture, $info);#just get what we need
$posts="$info[1]";
$posts_array=preg_split("/$sep/",$posts);#separate posts into array
$posts_array=str_replace('<br />',"\n",$posts_array);#turn br into newline
if ($keepimages=="yes"){
  $posts_array=preg_replace("/<img .*src=\"(.*)\" *\/>/","[img=$1]",$posts_array);# get img src
}
$posts_array=preg_replace("/(<\/?)(\w+)([^>]*>)/","",$posts_array);# get rid of all tags
$posts_array=preg_replace("/\n+/","<br>",$posts_array);#turn newlines back into br
$f=fopen("blog.txt","w");
fwrite($f,implode("\n",$posts_array));
fclose($f);
# file is saved as a txt file. each line is a post. Manipulate in excel as required.
print "<a href='blog.txt'>Download this</a>";
#CLOSE ENOUGH!!!
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.