Skip to content

Commit

Permalink
Update source
Browse files Browse the repository at this point in the history
Update source
  • Loading branch information
zzzprojects committed Jul 22, 2017
1 parent c3573e6 commit 31a3a02
Show file tree
Hide file tree
Showing 4 changed files with 436 additions and 461 deletions.
2 changes: 1 addition & 1 deletion src/HtmlAgilityPack.Shared/HtmlDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ private string[] GetResetters(string name)
switch (name)
{
case "li":
return new string[] {"ul"};
return new string[] {"ul", "ol"};

case "tr":
return new string[] {"table"};
Expand Down
99 changes: 90 additions & 9 deletions src/HtmlAgilityPack.Shared/HtmlWeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,16 @@ public HtmlDocument Load(string url)
return Load(url, "GET");
}

/// <summary>
/// Gets an HTML document from an Internet resource.
/// </summary>
/// <param name="uri">The requested Uri, such as new Uri("http://Myserver/Mypath/Myfile.asp").</param>
/// <returns>A new HTML document.</returns>
public HtmlDocument Load(Uri uri)
{
return Load(uri, "GET");
}

#if !NETSTANDARD
/// <summary>
/// Gets an HTML document from an Internet resource.
Expand Down Expand Up @@ -1180,20 +1190,62 @@ public HtmlDocument Load(string url, string proxyHost, int proxyPort, string use
}
#endif

#if !NETSTANDARD
/// <summary>
/// Gets an HTML document from an Internet resource.
/// </summary>
/// <param name="uri">The requested Uri, such as new Uri("http://Myserver/Mypath/Myfile.asp").</param>
/// <param name="proxyHost">Host to use for Proxy</param>
/// <param name="proxyPort">Port the Proxy is on</param>
/// <param name="userId">User Id for Authentication</param>
/// <param name="password">Password for Authentication</param>
/// <returns>A new HTML document.</returns>
public HtmlDocument Load(Uri uri, string proxyHost, int proxyPort, string userId, string password)
{
//Create my proxy
WebProxy myProxy = new WebProxy(proxyHost, proxyPort);
myProxy.BypassProxyOnLocal = true;

//Create my credentials
NetworkCredential myCreds = null;
if ((userId != null) && (password != null))
{
myCreds = new NetworkCredential(userId, password);
CredentialCache credCache = new CredentialCache();
//Add the creds
credCache.Add(myProxy.Address, "Basic", myCreds);
credCache.Add(myProxy.Address, "Digest", myCreds);
}

return Load(uri, "GET", myProxy, myCreds);
}
#endif

/// <summary>
/// Loads an HTML document from an Internet resource.
/// </summary>
/// <param name="url">The requested URL, such as "http://Myserver/Mypath/Myfile.asp".</param>
/// <param name="method">The HTTP method used to open the connection, such as GET, POST, PUT, or PROPFIND.</param>
/// <returns>A new HTML document.</returns>
public HtmlDocument Load(string url, string method)
{
Uri uri = new Uri(url);

return Load(uri, method);
}
/// <summary>
/// Loads an HTML document from an Internet resource.
/// </summary>
/// <param name="uri">The requested URL, such as new Uri("http://Myserver/Mypath/Myfile.asp").</param>
/// <param name="method">The HTTP method used to open the connection, such as GET, POST, PUT, or PROPFIND.</param>
/// <returns>A new HTML document.</returns>
public HtmlDocument Load(Uri uri, string method)
{
if (UsingCache)
{
_usingCacheAndLoad = true;
}

Uri uri = new Uri(url);
HtmlDocument doc;
#if !NETSTANDARD
if ((uri.Scheme == Uri.UriSchemeHttps) ||
Expand All @@ -1219,9 +1271,9 @@ public HtmlDocument Load(string url, string method)
doc.OptionAutoCloseOnEnd = false;
doc.OptionAutoCloseOnEnd = true;
if (OverrideEncoding != null)
doc.Load(url, OverrideEncoding);
doc.Load(uri.OriginalString, OverrideEncoding);
else
doc.DetectEncodingAndLoad(url, _autoDetectEncoding);
doc.DetectEncodingAndLoad(uri.OriginalString, _autoDetectEncoding);
}
else
{
Expand All @@ -1245,13 +1297,29 @@ public HtmlDocument Load(string url, string method)
/// <param name="credentials">Credentials to use when authenticating</param>
/// <returns>A new HTML document.</returns>
public HtmlDocument Load(string url, string method, WebProxy proxy, NetworkCredential credentials)
{
Uri uri = new Uri(url);

return Load(uri, method, proxy, credentials);
}
#endif

#if !NETSTANDARD
/// <summary>
/// Loads an HTML document from an Internet resource.
/// </summary>
/// <param name="uri">The requested Uri, such as new Uri("http://Myserver/Mypath/Myfile.asp").</param>
/// <param name="method">The HTTP method used to open the connection, such as GET, POST, PUT, or PROPFIND.</param>
/// <param name="proxy">Proxy to use with this request</param>
/// <param name="credentials">Credentials to use when authenticating</param>
/// <returns>A new HTML document.</returns>
public HtmlDocument Load(Uri uri, string method, WebProxy proxy, NetworkCredential credentials)
{
if (UsingCache)
{
_usingCacheAndLoad = true;
}

Uri uri = new Uri(url);
HtmlDocument doc;
if ((uri.Scheme == Uri.UriSchemeHttps) ||
(uri.Scheme == Uri.UriSchemeHttp))
Expand All @@ -1265,7 +1333,7 @@ public HtmlDocument Load(string url, string method, WebProxy proxy, NetworkCrede
doc = new HtmlDocument();
doc.OptionAutoCloseOnEnd = false;
doc.OptionAutoCloseOnEnd = true;
doc.DetectEncodingAndLoad(url, _autoDetectEncoding);
doc.DetectEncodingAndLoad(uri.OriginalString, _autoDetectEncoding);
}
else
{
Expand All @@ -1279,7 +1347,6 @@ public HtmlDocument Load(string url, string method, WebProxy proxy, NetworkCrede
return doc;
}
#endif

#if NET45 || NETSTANDARD
/// <summary>
/// Loads an HTML document from an Internet resource.
Expand All @@ -1291,12 +1358,27 @@ public HtmlDocument Load(string url, string method, WebProxy proxy, NetworkCrede
/// <returns>A new HTML document.</returns>
public HtmlDocument Load(string url, string method, IWebProxy proxy, ICredentials credentials)
{
Uri uri = new Uri(url);
return Load(uri, method, proxy, credentials);
}
#endif

#if NET45 || NETSTANDARD
/// <summary>
/// Loads an HTML document from an Internet resource.
/// </summary>
/// <param name="uri">The requested Uri, such as new Uri("http://Myserver/Mypath/Myfile.asp").</param>
/// <param name="method">The HTTP method used to open the connection, such as GET, POST, PUT, or PROPFIND.</param>
/// <param name="proxy">Proxy to use with this request</param>
/// <param name="credentials">Credentials to use when authenticating</param>
/// <returns>A new HTML document.</returns>
public HtmlDocument Load(Uri uri, string method, IWebProxy proxy, ICredentials credentials)
{
if (UsingCache)
{
_usingCacheAndLoad = true;
}

Uri uri = new Uri(url);
HtmlDocument doc;
#if !NETSTANDARD
if (uri.Scheme == Uri.UriSchemeFile)
Expand All @@ -1319,7 +1401,7 @@ public HtmlDocument Load(string url, string method, IWebProxy proxy, ICredential
doc = new HtmlDocument();
doc.OptionAutoCloseOnEnd = false;
doc.OptionAutoCloseOnEnd = true;
doc.DetectEncodingAndLoad(url, _autoDetectEncoding);
doc.DetectEncodingAndLoad(uri.OriginalString, _autoDetectEncoding);
}
else
{
Expand All @@ -1333,7 +1415,6 @@ public HtmlDocument Load(string url, string method, IWebProxy proxy, ICredential
return doc;
}
#endif

#if !NETSTANDARD
/// <summary>
/// Loads an HTML document from an Internet resource and saves it to the specified XmlTextWriter.
Expand Down
Loading

0 comments on commit 31a3a02

Please sign in to comment.