I've only just picked up this question, and have now visited Twitter.com exactly once with my browser.
I tried your code and found that I received the entire html, not just the small exerpt that you show above. I then tried to save the response to a file (C:\002\twatter.html) and open that with Chrome to see what it looked like. The only problem was that every time I tried to open the blessed thing, the address bar of my browser would then show
"file:///C:/#!/search/cts/grid?q=cts" and the browser window would show a file listing of the root of my C: drive. Hmmm, hmmm, hmmm.
So I took a closer look inside the response html, and whaddya know - line #9 contained this little gem:
window.location.replace('/#!/search/cts/grid?q=cts');
So I tried to enter this url manually, swapping file:///C:/ with twitter.com - to form the url:
http://twitter.com/#!/search/cts/grid?q=cts[
^]
Sooooo, I guess you can submit the request as normal before buffering the response and searching for the line that begins with "window.location.replace". You could then extract the text contained within the quotes, append that onto the end of the string "www.twitter.com". Once done, you could submit a request for this newly formed url, which in this example given will return a page that (at the time of writing) contains 3 images - some bike riders, an album cover and some people singing.
For reference, here is the returned html from the first request, and the code I used to nab it:
Hope this is the key you require.
Cheers!
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
//<![CDATA[
</script>
<script type="text/javascript">
//<![CDATA[
</script>
<script type="text/javascript">
//<![CDATA[
</script>
<script type="text/javascript">
//<![CDATA[
</script>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="en-us" http-equiv="Content-Language" />
<meta content="Twitter is without a doubt the best way to share and discover what is happening right now." name="description" />
<meta content="no" http-equiv="imagetoolbar" />
<meta content="width = 780" name="viewport" />
<meta content="4FTTxY4uvo0RZTMQqIyhh18HsepyJOctQ+XTOu1zsfE=" name="verify-v1" />
<meta content="1" name="page" />
<meta content="NOODP" name="robots" />
<meta content="n" name="session-loggedin" />
<title id="page_title">Twitter / Search</title>
<link href="https://si0.twimg.com/a/1308256633/images/twitter_57.png" rel="apple-touch-icon" />
<link href="/oexchange.xrd" rel="http://oexchange.org/spec/0.8/rel/related-target" type="application/xrd+xml" />
<link href="https://si0.twimg.com/a/1308256633/images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link href="https://si0.twimg.com/a/1308256633/stylesheets/fronts.css?1308259136" media="screen" rel="stylesheet" type="text/css" />
</head>
<body class="timeline ie ie8 front" id="search">
<script type="text/javascript">
//<![CDATA[
</script>
<div id="header">
<div class="background">
<div class="inner">
<div id="logo-search">
<a href="/" id="logo"><img alt="Twitter" height="55" src="https://si0.twimg.com/a/1308256633/images/fronts/logo_withbird_home.png" width="224" /></a>
<form action="/search" id="home_search" method="post"><div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="23f64499bc7bd8f3b4dc82d221063563caabe68d" /></div>
<p>
<input accesskey="/" class="round-left" id="searchform_q" name="q" size="30" tabindex="8" type="text" value="cts" /><input class="submit round-right" id="searchform_submit" name="commit" tabindex="9" type="submit" value="Search" />
</p>
</form>
<p id="tag">
The best way to discover what’s new in your world.
</p>
</div>
<div id="topnav">
<div id="signin-c">
<div id="signin_controls">
<span id="have_an_account">
Have an account?<a href="/login" class="signin" tabindex="3"><span>Sign in</span></a></span>
<div id="signin_menu" class="common-form standard-form offscreen">
<form method="post" id="signin" action="https://twitter.com/sessions">
<input id="authenticity_token" name="authenticity_token" type="hidden" value="23f64499bc7bd8f3b4dc82d221063563caabe68d" /> <input id="return_to_ssl" name="return_to_ssl" type="hidden" value="true" />
<input id="redirect_after_login" name="redirect_after_login" type="hidden" value="/search/cts/grid" /> <p class="textbox">
<label for="username">Username or email</label>
<input type="text" id="username" name="session[username_or_email]" value="" title="username" tabindex="4"/>
</p>
<p class="textbox">
<label for="password">Password</label>
<input type="password" id="password" name="session[password]" value="" title="password" tabindex="5"/>
</p>
<p class="remember">
<input type="submit" id="signin_submit" value="Sign in" tabindex="7"/>
<input type="checkbox" id="remember" name="remember_me" value="1" tabindex="6"/>
<label for="remember">Remember me</label>
</p>
<p class="forgot">
<a href="/account/resend_password" id="resend_password_link">Forgot password?</a>
</p>
<p class="forgot-username">
<a href="/account/resend_password" id="forgot_username_link" title="If you remember your password, try logging in with your email">Forgot username?</a>
</p>
<p class="complete">
<a href="/account/complete" id="account_complete_link">Already using Twitter on your phone?</a>
</p>
<input type="hidden" name="q" id="signin_q" value="cts"/>
</form>
</div>
</div>
</div>
</div>
<div class="overlay">
<div class="newuser">
<h2>New to Twitter?</h2>
<p>Easy, free, and instant updates. Get access to the information that interests you most.</p>
<p id="signup-btn"><a href="/signup" id="signup_submit" tabindex="10"><span>Sign Up ›</span></a></p>
<h2>Discover Twitter</h2>
<p><a href="http://discover.twitter.com/?autoplay=true">Find out how</a> some of your favorite people use Twitter.</p>
<p><a href="http://discover.twitter.com/?autoplay=true" id="video-thumb"><img alt="Discover-video" height="140" src="https://si0.twimg.com/a/1308256633/images/fronts/discover-video.png" width="200" /></a></p>
</div>
</div>
</div>
</div>
<div id="trends">
<div class="inner">
<ul class="trendscontent">
<li class="trend-label">Trending topics</li>
<li>
<a href="http://twitter.com/search?q=%22Brittany%20Murphy%22" class="search_link" name=""Brittany Murphy"" rel="nofollow">Brittany Murphy</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22Penn%20&%20Teller%22" class="search_link" name=""Penn & Teller"" rel="nofollow">Penn & Teller</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22Epic%20Movie%22" class="search_link" name=""Epic Movie"" rel="nofollow">Epic Movie</a>
</li>
<li>
<a href="http://twitter.com/search?q=Ighalo" class="search_link" name="Ighalo" rel="nofollow">Ighalo</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22Glen%20Coco%22" class="search_link" name=""Glen Coco"" rel="nofollow">Glen Coco</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22Her%20Room%22" class="search_link" name=""Her Room"" rel="nofollow">Her Room</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22Mauro%20Diaz%22" class="search_link" name=""Mauro Diaz"" rel="nofollow">Mauro Diaz</a>
</li>
<li class="trend-label">Trending topics</li>
<li>
<a href="http://twitter.com/search?q=%22Teyana%20Taylor%22" class="search_link" name=""Teyana Taylor"" rel="nofollow">Teyana Taylor</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22Lar%20Doce%20Lar%22" class="search_link" name=""Lar Doce Lar"" rel="nofollow">Lar Doce Lar</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22Jos%C3%A9%20Saramago%22" class="search_link" name=""José Saramago"" rel="nofollow">José Saramago</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22Brigitte%20Kaandorp%22" class="search_link" name=""Brigitte Kaandorp"" rel="nofollow">Brigitte Kaandorp</a>
</li>
<li>
<a href="http://twitter.com/search?q=Elche-Granada" class="search_link" name="Elche-Granada" rel="nofollow">Elche-Granada</a>
</li>
<li>
<a href="http://twitter.com/search?q=Wetten" class="search_link" name="Wetten" rel="nofollow">Wetten</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22Undisclosed%20Desires%22" class="search_link" name=""Undisclosed Desires"" rel="nofollow">Undisclosed Desires</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22SCORPIOS%20RULE%22" class="search_link" name=""SCORPIOS RULE"" rel="nofollow">SCORPIOS RULE</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22Bald%20Gaga%22" class="search_link" name=""Bald Gaga"" rel="nofollow">Bald Gaga</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22Maria%20Desamparada%22" class="search_link" name=""Maria Desamparada"" rel="nofollow">Maria Desamparada</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22United%20Airlines%22" class="search_link" name=""United Airlines"" rel="nofollow">United Airlines</a>
</li>
<li>
<a href="http://twitter.com/search?q=%22Ryan%20Reynolds%22" class="search_link" name=""Ryan Reynolds"" rel="nofollow">Ryan Reynolds</a>
</li>
</ul>
</div>
<span class="fade fade-left"> </span><span class="fade fade-right"> </span>
</div>
</div>
<ul id="accessibility" class="offscreen">
<li><a href="#content" accesskey="0">Skip past navigation</a></li>
<li>On a mobile phone? Check out <a href="http://m.twitter.com/">m.twitter.com</a>!</li>
<li><a href="#footer" accesskey="2">Skip to navigation</a></li>
<li><a href="#signin">Skip to sign in form</a></li>
</ul>
<div class="content-wrapper">
<div id="content" class="homepage">
<div class="section clearfix">
<div class="aside">
<div class="trenddesc" style="display:none">
<span class="trending">Trending Now</span>
<div id="trend"></div>
<div id="trend_description"><p></p></div>
<div id="what_the_trend">Source: <span>What the Trend?</span></div>
</div>
<div class="current-trends" style="display:none">
<h3>Top Trending Topics</h3>
<ul>
<li><a href="http://twitter.com/search?q=%23howtopleaseahoodrat" class="search_link" name="#howtopleaseahoodrat" rel="nofollow">#howtopleaseahoodrat</a></li>
<li><a href="http://twitter.com/search?q=%23nextfriday" class="search_link" name="#nextfriday" rel="nofollow">#nextfriday</a></li>
<li><a href="http://twitter.com/search?q=%23trespalabrasespanolas" class="search_link" name="#trespalabrasespanolas" rel="nofollow">#trespalabrasespanolas</a></li>
<li><a href="http://twitter.com/search?q=%22Brittany%20Murphy%22" class="search_link" name=""Brittany Murphy"" rel="nofollow">Brittany Murphy</a></li>
<li><a href="http://twitter.com/search?q=%22Penn%20&%20Teller%22" class="search_link" name=""Penn & Teller"" rel="nofollow">Penn & Teller</a></li>
<li><a href="http://twitter.com/search?q=%22Epic%20Movie%22" class="search_link" name=""Epic Movie"" rel="nofollow">Epic Movie</a></li>
<li><a href="http://twitter.com/search?q=Ighalo" class="search_link" name="Ighalo" rel="nofollow">Ighalo</a></li>
<li><a href="http://twitter.com/search?q=%22Glen%20Coco%22" class="search_link" name=""Glen Coco"" rel="nofollow">Glen Coco</a></li>
<li><a href="http://twitter.com/search?q=%22Her%20Room%22" class="search_link" name=""Her Room"" rel="nofollow">Her Room</a></li>
<li><a href="http://twitter.com/search?q=%22Mauro%20Diaz%22" class="search_link" name=""Mauro Diaz"" rel="nofollow">Mauro Diaz</a></li>
</ul>
</div>
<div class="search-tip" style="display:none">
<h3>Search tip</h3>
<div>Use <em>:(</em> to find tweets with a negative or sad attitude. Example: <a href="/search?q=flight+%3A%28">flight :(</a> will find tweets containing "flight" and with a negative attitude.</div>
</div>
<div style="height:285px"></div>
</div>
<div class="article">
<div id="tweets" data="{timeout:8000}">
<h2>Top Tweets <a id="view_all_top_tweets" href="toptweets/favorites" tabindex="11">View all</a></h2>
<script src="https://si0.twimg.com/a/1308256633/javascripts/widgets/widget.js?1308259133" type="text/javascript"></script>
<script type="text/javascript">
//height was 202 to match 5 lines of sources
new TWTR.Widget({
version: 2,
type: 'faves',
rpp: 40,
interval: 6000,
title: 'Noteworthy tweets',
subject: '',
width: 'auto',
height: '270',
theme: {
shell: {
background: '#ffffff',
color: '#333333'
},
tweets: {
background: '#ffffff',
color: '#333333',
links: '#2276bb'
}
},
features: {
scrollbar: false,
loop: true,
live: true,
hashtags: true,
timestamp: true,
avatars: true,
behavior: 'preloaded'
}
}).render().setUser("toptweets").start();
</script>
</div>
<div id="results" style="display: none">
<h2 id="timeline_heading">Realtime results for <span></span></h2>
<div data="{"search":{"delay":20,"decay":1.25,"max_delay":180},"timeline":{"max_refresh_size":40,"delay":30,"decay":1.5,"max_delay":300}}" id="new_results_notification"><a accesskey="n" class="minor-notification" id="results_update" style="display:none;"></a></div>
<div class="no-results"></div>
<ol id="timeline" class="statuses"></ol>
<div id="pagination"></div>
</div>
</div>
</div>
</div>
</div>
<div class="footer-wrapper">
<div id="footer" class="round wide">
<h3 class="offscreen">Footer</h3>
<form action="/sessions/change_locale" id="lf" method="post" style="display:none;"><div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="23f64499bc7bd8f3b4dc82d221063563caabe68d" /></div>
<input type="hidden" name="lang" id="lang" value="en"/>
</form>
<ul class="language-select"><li>Language:</li><li><a href="#" class="locale">English</a> <a href="#" class="arrow">▼</a></li></ul>
<ol class="language-menu round">
<li id="pt">Portuguese - Português</li>
<li id="it">Italian - Italiano</li>
<li id="es">Spanish - Español</li>
<li id="tr">Turkish - Türkçe</li>
<li id="en">English</li>
<li id="ko">Korean - 한국어</li>
<li id="fr">French - français</li>
<li id="ru">Russian - Русский</li>
<li id="de">German - Deutsch</li>
<li id="ja">Japanese - 日本語</li>
</ol>
<ul class="footer-nav">
<li class="first">© 2011 Twitter</li>
<li><a href="/about">About Us</a></li>
<li><a href="/about/contact">Contact</a></li>
<li><a href="http://blog.twitter.com">Blog</a></li>
<li><a href="http://status.twitter.com">Status</a></li>
<li><a href="/about/resources">Resources</a></li>
<li><a href="http://dev.twitter.com/">API</a></li>
<li><a href="http://twitter.com/business">Business</a></li>
<li><a href="http://support.twitter.com">Help</a></li>
<li><a href="/help/jobs">Jobs</a></li>
<li><a href="/tos">Terms</a></li>
<li><a href="/privacy">Privacy</a></li>
</ul>
</div>
</div>
<div class="trendtip">
<div class="trendtip-content">
<div>Trending right now:</div>
<a class="trendtip-trend"></a>
<div class="trendtip-why">
Why?
<span class="trendtip-desc"></span>
<span class="trendtip-source">Source: <span>What the Trend?</span></span>
</div>
</div>
<div class="trendtip-pointer"> </div>
</div>
<div id="notifications"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js" type="text/javascript"></script>
<script src="https://si0.twimg.com/a/1308256633/javascripts/fronts-https.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
</script>
<script type="text/javascript">
//<![CDATA[
</script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-30775-6");
pageTracker._setDomainName("twitter.com");
pageTracker._setVar('Not Logged In');
pageTracker._setVar('lang: en');
pageTracker._initData();
} catch(err) { }
</script>
</body>
</html>
void doTwatterSearch()
{
HINTERNET hOpen =InternetOpen ( "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1)",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0);
HINTERNET hConnect= InternetConnect (
hOpen,
"www.twitter.com",
INTERNET_DEFAULT_HTTPS_PORT,
"",
"",
INTERNET_SERVICE_HTTP,
0,
0
);
LPCSTR lpData(""),*lpPtr;
lpPtr=&lpData;
HINTERNET hReq = HttpOpenRequest (
hConnect,
"GET",
"/?_escaped_fragment_=/search/cts",
HTTP_VERSION,
"",
(const CHAR**)"text/*",
INTERNET_FLAG_SECURE,
0
);
DWORD dwBytes;
FILE *fp;
char ch=' ';
if(HttpSendRequest(hReq,NULL,0,NULL,0))
{
fp = (FILE*)fopen("C:\\002\\twatter.html", "w+");
while(InternetReadFile(hReq,&ch,1,&dwBytes))
{
if(dwBytes != 1) break;
fprintf(fp, "%c", ch);
}
fclose(fp);
}
}