src of image (help help help) - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

src of image (help help help)

royaroya Posts: 18Member
Hello,
Please help me.
I have written a program that get a url and show the web page . I must read source of the web page and find img tags and so on. Then I should download them with WebDownload Function .
But I have a problem. When there is some variable of pages in the tag I dont know what will I do. Because I dont know how can I access to the value of these variables. Please help me. Its very emergency.

Example of such tags:
< img src="add/bb/" + browD + ".gif"

in this example browD is a internal variable in page. ( my code is in c#)

Comments

  • iwilld0itiwilld0it Posts: 1,134Member
    Well if the code is C# (not javascript), then you should have no problem. However this depends on how you are requesting the web page ...

    If you are using a WebRequest and WebResponse object, the code in the website should be parsed and converted completely to HTML automatically. Then it is a matter of parsing the image tags out.

    If you are phsyically opening the ASPX file using the filesystem classes, then you are mostly out of luck. You could write a regular expression to parse out image variables, but you can not really predict all the formats.


  • royaroya Posts: 18Member
    : Well if the code is C# (not javascript), then you should have no problem. However this depends on how you are requesting the web page ...
    :
    : If you are using a WebRequest and WebResponse object, the code in the website should be parsed and converted completely to HTML automatically. Then it is a matter of parsing the image tags out.
    :
    : If you are phsyically opening the ASPX file using the filesystem classes, then you are mostly out of luck. You could write a regular expression to parse out image variables, but you can not really predict all the formats.
    :
    : hello,
    1) my code gets an url and makes a request for it . then manipulates source of response. It uses webRequest and webResponse .
    it uses below code for getting source of the code in string.

    Stream objStream = wrResponse.GetResponseStream();
    StreamReader objStreamReader = new StreamReader(objStream);
    String src=objStreamReader.ReadToEnd();

    So I can't restore the value of internal variables from src variable because it is a string.
    What do you think of this : May be I can solve this problem by writing javascript code . for example by adding a javascript code in source of a webpage that this code read source of img tags and write them at a text file.( because when writing sourc of objects by this way internal variables will replace) .
    I have writed such code that write source of image tags by below code :
    Document.write (document.images(i).src)
    For each of img tags and I've got correct result . but I could not write resuls in to a file.(with javascript language) . can you help me ?

    :

Sign In or Register to comment.