[C#] Google URL Image Searching (Good to find Fakes)

Toyz
by Toyz · 3 posts
11 years ago in .Net (C#, VB, etc)
Posted 11 years ago · Author
Well I haven't designed a main page to handle the posting to it yet, but anyone with a brain of a pea can do it :)

Code
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Net;

namespace Toyz_Portfoilo.sBin
{
 public class SBIHelper
    {
        public static string SearchByImage(string URL)
        {
            HttpWebRequest request = WebRequest.Create(String.Format("http://www.google.com/searchbyimage?hl=en&site=search&image_url={0}", URL)) as HttpWebRequest;
            StringBuilder sb = new StringBuilder();
            string ImageName;
            byte[] buf = new byte[8192];

            request.Method = "GET";
            request.ProtocolVersion = HttpVersion.Version11;
            request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0";

            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            var stream = response.GetResponseStream();

            string tempString = null;
            int count = 0;

            do
            {
                count = stream.Read(buf, 0, buf.Length);
                if (count != 0)
                {
                    tempString = Encoding.ASCII.GetString(buf, 0, count);
                    sb.Append(tempString);
                }
            }
            while (count > 0);

            string re1 = "(;)";
            string re2 = "(q)";
            string re3 = "(=)";
            string re4 = "((?:[a-z][a-z]+))";
            string re5 = ".*?";
            string re6 = "(&)";

            Regex r = new Regex(re1 + re2 + re3 + re4 + re5 + re6, RegexOptions.IgnoreCase | RegexOptions.Singleline);

            Match match = r.Match(sb.ToString());
            if (match.Success)
                ImageName = match.ToString().Remove(0, 3).TrimEnd('&').Replace("%20", " ");
            else
                ImageName = null;
                       
            return ImageName;
        }
    }
}


And to use is press simple

Code
public void main()
{
 console.writeLine(SBIHelper.SearchByImage({image url}));
}
Posted 11 years ago
My brain must be smaller than a pea. Mostly I am not as familiar with C# so that last piece of code stumps me as to where it's supposed to be put and called from.
Posted 11 years ago
Ð▪ℳ wrote:
My brain must be smaller than a pea. Mostly I am not as familiar with C# so that last piece of code stumps me as to where it's supposed to be put and called from.


The last line is just the main class. (the root of her code which calls up everything else)
All it does is send the image url to the SBIHelper helper class's SearchByImage function. (it passes the image's web address to the rest of her code to work with)
Then it writes the data to the console's output stream. (it write the output to the screen)

Oh, and your brain is not smaller than a pea.
If it was, you would not be my right hand man.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT
Select a forum Protection     Help & Support     Introductions     Mafia News     IMVU News General Discussion     IMVU Lounge        IMVU Series / Roleplaying        Social Games     Mafia Market     Mafia Tools        Premium IMVU Tools        Off Topic Tools     Off Topic     Contests Creator Corner     Graphics Design        Photoshop        GIMP     Basic Creator Help     Catalog And Product Showcase     3D Meshing        3Ds Max        Sketchup        Blender Gangsters with Connections     White Hat Activities        Google Hacking        Trackers Programming Corner     Coding        Python        .Net (C#, VB, etc)        Flash        JAVA        Autoit        Batch        HTML & CSS        Javascript        PHP        Other        IMVU Homepage Codes           General           About me Panel           Messages Panel           Special Someone Panel           Visitors Panel           New Products Panel           Rankings Panel           Wishlist Panel           My Badges Panel           Outfits Panel           Url Panel           Groups Panel           Slideshow Panel           My Room Panel           Sandbox panel           Layouts     Help & Requests Free Credits     Approved Methods     Submit Methods Free Money     Approved Methods     Submit Methods Adult Corner     Get Mafia AP Here     AP Lounge        AP Social Games        Casual Dating Tips     IMVU Slave Market & Escorts