I've lost full access to my sites and am trying to pass the posts on it to a new one. I have a code that reads the sitemap from it and takes the urls and another one that catches the url , separates the part that I need and put in my new site.
static void Main(string[] args)
{
var website = XMLReader("SITE");
Postagem(website.ToString());
Console.WriteLine("Total de Posts adicionados: " + website.Count());
Console.ReadLine();
}
When passing these urls to the function XMLReader
, with Postagem
, it returns me the error:
Error: System.UriFormatException: Invalid URI: The format of the URI could not be determined.
But if I pass:
Postagem("LINK DO POST");
He puts everything right. What would be the mistake? I did not find anything on the net.
private static void Postagem(string website)
{
try
{
string link = "SITE";
string username = "USER_WP";
string password = "SENHA_WP";
HtmlWeb web = new HtmlWeb();
HtmlDocument resultat = web.Load(website);
string titulopost = resultat.DocumentNode.SelectNodes("//*[contains(@class,'entry-title')]")[0].InnerHtml;
string conteudo = resultat.DocumentNode.SelectNodes("//*[contains(@class,'entry-content')]")[0].InnerHtml;
var wp = new WordPressWrapper(link + "/xmlrpc.php", username, password);
var post = new Post();
Console.WriteLine("Adicionando post: " + titulopost);
post.DateCreated = DateTime.Today.AddHours(0);
post.Title = titulopost;
post.Body = conteudo;
wp.NewPost(post, true);
}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e);
}
}