How do I search for a string with quotes?

Posted by every_answer_gets_a_point on Stack Overflow See other posts from Stack Overflow or by every_answer_gets_a_point
Published on 2010-04-13T17:27:32Z Indexed on 2010/04/13 18:03 UTC
Read the original article Hit count: 290

Filed under:

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 incorrect.

Here are the first couple hundred characters of the string HTML:

<!doctype html><head><title>Santarus Inc&#8206; - 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

© Stack Overflow or respective owner

Related posts about c#