I am searching for the string
<!--m--><li class="g w0"><h3 class=r><a href="
within the HTML source of this link:
http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=Santarus+Inc
This is how I am searching for it:
string html_string = "http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=" + biocompany;
html = new WebClient().DownloadString(html_string);
d=html.IndexOf(@"<!--m--><li class=""g w0""><h3 class=r><a href=""",1);
For some reason it is finding an occurrence of it at position 45 (in other words d=45) but this is incorrect.
Here are the first couple hundred characters of the string HTML:
<!doctype html><head><title>Santarus Inc‎ - Google Search</title><script>window.google={kEI:\"b6jES5nPD4rysQOokrGDDQ\",kEXPI:\"23729,24229,24249,24260,24414,24457\",kCSI:{e:\"23729,24229,24249,24260,24414,24457\",ei:\"b6jES5nPD4rysQOokrGDDQ\",expi:\"23729,24229,24249,24260,24414,24457\"},ml:function(){},kHL:\"en\",time:function(){return(new Date).getTime()},log:function(b,d,c){var a=new Image,e=google,g=e.lc,f=e.li;a.onerror=(a.onload=(a.onabort=function(){delete g[f]}));g[f]=a;c=c||\"/gen_204?atyp=i&ct=\"+b+\"&cad=\"+d+\"&zx=\"+google.time();a.src=c;e.li=f+1},lc:[],li:0,Toolbelt:{}};\nwindow.google.sn=\"web\";window.google.timers={load:{t:{start:(new Date).getTime()}}};try{}catch(u){}window.google.jsrt_kill=1;\n</script><style>body{background:#fff;color:#000;margin:3px 8px}#gbar,#guser{font-size:13px;padding-top:1px !important}#gbar{float:left;height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh
Post more code. My guess is your html variable isn’t storing what you think it is. Are you reading the html line by line, by chance? And are you appending or replacing the prior contents? At any rate, put a breakpoint immediately before or after the .IndexOf call and check the contents of html.
Edit I ran through a sample of your code and am not finding your string.
I am not sure what you are doing based on the code you posted.