How can I get an image from a site in my program?

Good day. There is a site that has posted ads here I need to get a phone number on the page of any ad, for example here Phone number is represented as an image. I wanted to get a link to a picture and save this picture and recognize this picture. But when I started getting a link to the picture in my program, I saw that a java script appeared in this picture. Here is the code where I am trying to get a link to a picture in my program:

.....
HtmlNode bodyNode7 = doc.DocumentNode.SelectSingleNode(@".//*//table[6][@class='objectView']//tr[2]//td");
Console.WriteLine(bodyNode7.InnerText.ToString());
.....

      

I am using HtmlAgilityPack library (C #) to parse an image link. I opened the source for this page ( here ) and saw the Javascript that generates the image:

<tr id="ctl00_cphBody_FlatSell_Obj_adapterObject_trPhones" style="background-color: white">
        <th>:</th>
        <td>
                    <script language="javascript" type="text/javascript">document.write(decs("0x88e36b6d468b03acca9737a99ba0fffe05cb3a53de8858b798194826c94719e2193434b3377d69745a1a28879291ecfd69c703de931ac8f551fe22229ef49160"));</script>
        </td>
</tr>

      

The javascript uses the decs () function to generate an image. Here is the code:

function decs(a){
return deco(key,hexToString(a),0,1,iv)
};

      

If I understood correctly, this function created a link to a picture with a phone number, or this function created this picture. In this case, the function uses the "key" parameter. I don't know how to create this parameter.

Question: How can I get a link to this picture with a phone number or download this picture with a phone number in my program?

+3


source to share


1 answer


You have several options. One is to use a library like OpenWebkitSharp that hosts a Webkit instance in your .NET application, you can use it to execute any scripts on the page and then check the resulting DOM to retrieve the images. The library is here: http://code.google.com/p/open-webkit-sharp/

However, hosting webkit in your application means it will take some time to load and will consume large amounts of memory. You will need to update it regularly so that webkit comes out almost weekly.

Another option, assuming the HTML and Javascript page is persistent, is to extract the functions using regular expressions and then do the transformation.



You will have a regex that finds the text " decs(

" and then extracts the hex encoded text, and then you use it in your own implementation of the function decs

, which should be easy to do.

NTN.

+1


source







All Articles