Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. I use code to get HTML source of a url , but there is a problem!!!

I use code to get HTML source of a url , but there is a problem!!!

Scheduled Pinned Locked Moved ASP.NET
htmlhelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nafiseh Salmani
    wrote on last edited by
    #1

    I use the following code to get HTML source of a url , but there is a problem!!!

    public string Gethtmlsourcecode(string url)
    {
    WebResponse response = null;
    WebRequest request = WebRequest.Create(url);
    response = request.GetResponse();
    string data = "";
    if ((response is HttpWebResponse && ((HttpWebResponse)response).StatusCode.ToString() == "OK") ||
    response is FileWebResponse)
    {
    StreamReader sr = new StreamReader(response.GetResponseStream());

            data = sr.ReadToEnd();
        }
        return data;
    
    }
    

    whith this code for url : http://sme.ir/?p=product.profile&ProductID=53834[^] part of data which is an html source of the url should be

    <tr>
    <td class="l lf" width="35%">نام:</td>
    <td class="r rf">
    آماده سازی و بسته بندی قهوه-كاكائو-چای كیسه ای
    </td>
    </tr>
    <tr>
    <td class="l lf">نام‌ قانونی:</td>
    <td class="r rf">
    <a href='http://parstalat.sme.ir'>پارس طلعت</a>
    </td>
    </tr>

    but data is

    <tr>
    <td class="l lf" width="35%">نام:</td>
    <td class="r rf">

    	  </td>
    	</tr>
    					<tr>
    	  <td class="l lf">نام‌ قانونی:</td>
    	  <td class="r rf">
    	 	<a href='http://.sme.ir'></a>
    	  </td>
    	</tr>
    

    you can see some part of HTML source code is not in data!! what should i do to solve this problem?!!!

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups