Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello dear friend. i have a serious problem with Html Agility Pack. please see my code:

C#
Dim Scr1 As New HtmlWeb()
Dim Url1 = Scr1.Load("https://www.linkedin.com/in/ladan-sahraei-14461b34?authType=OUT_OF_NETWORK&authToken=tK-W&locale=en_US&srchid=4367283831473659871577&srchindex=1&srchtotal=6693647&trk=vsrp_people_res_name&trkInfo=VSRPsearchId%3A4367283831473659871577%2CVSRPtargetId%3A120972292%2CVSRPcmpt%3Aprimary%2CVSRPnm%3Afalse%2CauthType%3AOUT_OF_NETWORK")
Dim ournone As HtmlNode = Url1.DocumentNode.SelectSingleNode("//span[@class='full-name']")
Response.Write(ournone.InnerHtml)


when i run this code i have a poblem:
C#
Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 


when i save content of the page in a html file and run code again it work well.

C#
Dim Scr1 As New HtmlWeb()
Dim Url1 = Scr1.Load("http://localhost:21374/HtmlPage.html")
Dim ournone As HtmlNode = Url1.DocumentNode.SelectSingleNode("//span[@class='full-name']")
Response.Write(ournone.InnerHtml)


what is problem?

What I have tried:

problem on Html Agility Pack. please help me
Posted
Updated 11-Sep-16 21:59pm

1 solution

hello dear friend. i have a serious problem with Html Agility Pack. please see my code:

the first code when run on a saved file on system work correct but not work with the same content in a online url and return empty values:

is work empty value!
C#
Dim Scr1 As New HtmlWeb()
Dim Url1 = Scr1.Load("https://www.linkedin.com/in/ladan-sahraei-14461b34?authType=OUT_OF_NETWORK&authToken=tK-W&locale=en_US&srchid=4367283831473659871577&srchindex=1&srchtotal=6693647&trk=vsrp_people_res_name&trkInfo=VSRPsearchId%3A4367283831473659871577%2CVSRPtargetId%3A120972292%2CVSRPcmpt%3Aprimary%2CVSRPnm%3Afalse%2CauthType%3AOUT_OF_NETWORK")
Dim ournone As HtmlNode = Url1.DocumentNode.SelectSingleNode("//span[@class='full-name']")
Response.Write(ournone.InnerHtml)


is work correct!
C#
Dim Scr1 As New HtmlWeb()
Dim Url1 = Scr1.Load("http://localhost:21374/HtmlPage.html")
Dim ournone As HtmlNode = Url1.DocumentNode.SelectSingleNode("//span[@class='full-name']")
Response.Write(ournone.InnerHtml)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900