HTMLDocument document = new HTMLDocument(webAddress); returns webaddress not found, but is valid address:
the code I tried:
Aspose.Html.License license = new Aspose.Html.License();
try
{
Aspose.Html.License htmlLicense = new Aspose.Html.License();
//license.SetLicense(“***.lic");
htmlLicense.SetLicense(".lic”);
Console.WriteLine("License set successfully.");
}
catch (Exception e)
{
Console.WriteLine("\nThere was an error setting the license: " + e.Message);
}
try //try String option 1
{
string webAddress = “https://www.google.com/”;
HTMLDocument document0 = new HTMLDocument(webAddress);
}
catch
(Exception e)
{
Console.WriteLine(e.Message);
}
try
{
string webAddress = “https://www.google.com/”;
using (var document = new HTMLDocument(webAddress))
{
Console.WriteLine(document.DocumentElement.OuterHTML);
}
}
catch(Exception e)
{
Console.WriteLine(e.Message);
} //tryString optin 2
try
{
string webAddress = “https://www.google.com/”;
Url webAdressURL = new Url(webAddress);
HTMLDocument document0 = new HTMLDocument(webAdressURL);
}
catch
(Exception e)
{
Console.WriteLine(e.Message);
} // try url option 1
try
{
string webAddress = “https://www.google.com/”;
Url webAdressURL = new Url(webAddress);
using (var document = new HTMLDocument(webAdressURL))
{
// Write the document content to the output stream
Console.WriteLine(document.DocumentElement.OuterHTML);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
} // try url option 2
@Ksamples
It seems you are encountering an issue with loading an HTML document from a web address using Aspose.HTML. The error message “webAddress not found” typically indicates that the URL you are trying to access is either incorrect or unreachable at the moment.
Here are a few steps you can take to troubleshoot and resolve this issue:
-
Check the URL: Ensure that the URL you are using is correct and accessible. You can try opening the URL in a web browser to confirm that it is reachable.
-
Network Issues: Sometimes, network issues can prevent access to certain URLs. Make sure your internet connection is stable and that there are no firewall or proxy settings blocking the request.
-
Use the Correct Constructor: When creating an HTMLDocument
from a URL, ensure you are using the correct constructor. You can create an HTMLDocument
using a Url
instance, as shown in the following example:
string webAddress = "https://www.google.com/";
Url webAddressURL = new Url(webAddress);
HTMLDocument document = new HTMLDocument(webAddressURL);
-
Error Handling: Implement error handling to catch specific exceptions. This can help you identify the exact issue. For example, if the URL is unreachable, you might receive a DOMException
with a specialized code indicating a network error.
-
Review Documentation: For more detailed guidance on loading HTML documents from URLs, you can refer to the official documentation, which provides examples and explanations on how to handle such scenarios effectively.
If you continue to experience issues, consider checking the Aspose forums for similar problems or posting your specific error message for further assistance.
Sources:
[1]: Creating and Managing HTML Documents in Aspose.HTML for Java
[2]: Creating an HTML Document - Create or Load HTML | C#
i have tried the suggestions above. the error i get is always teh same
I copied the example code example and used the suggested url. I always get the same error:
DOMException: ‘https://docs.aspose.com/html/net/creating-a-document/document.html’ could not be found.
@Ksamples
We also faced an exception using below code:
Aspose.Html.Url url = new Aspose.Html.Url("https://google.com/");
// Initialize PdfSaveOptions
var options = new Aspose.Html.Saving.PdfSaveOptions();
// Convert the HTML code to PDF
Aspose.Html.Converters.Converter.ConvertHTML(url, options, dataDir + @"URLtoPDF.pdf");
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): HTMLNET-6044
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Thank-you for the response. How will I Know when the fix is available? Will someone respond to this thread when the update is available?
@Ksamples
Yes, we will send a notification here as soon as the ticket is resolved.
Thank-you! I an excited to start using our new product.
Could I please get an update on this issue? thanks.
@Ksamples
The ticket has been under the phase of the development and we are working on the issue fix. As soon as it is fixed, we will update you in this forum thread. Please spare us little time.
Understood… thanks for the update 
The issues you have found earlier (filed as HTMLNET-6044) have been fixed in this update. This message was posted using Bugs notification tool by avpavlysh
thank-you for the updates. I have downloaded them, but i am still getting the same error.
@Ksamples
We tested with the latest version of the API in our environment and could not notice any issues. Can you please share a sample console application in .zip format with us so that we can execute it in our environment to replicate the issue and address it accordingly?
Unfortunatly our organization will not allow us to foward source code outside our organization. Is their another way to do this?
here is the accii version of the code
try
{
string strUrl = “https://www.google.com”;
Url ul = new Url(strUrl);
using (var document = new HTMLDocument(ul))
{
var html = document.DocumentElement.OuterHTML;
// Write the document content to the output stream
Console.WriteLine(html);
}
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
@Ksamples
We are still unable to replicate the issue in our environment using the same code snippet that you shared with 25.1 version of the API. Can you please share your environment details where you are facing this issue? Are you still facing the same error? Please make sure that your application is able to access the system network as this seems more like an environment related issue.