您好,我有一个带有以下脚本的html页面(twitter.html)
<script type="text/javascript" charset="utf-8" src="http://widgets.twimg.com/j/2/widget.js"></script>
<script type="text/javascript">
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
var TwitterCount = getParameterByName('TwitterCount');
var TwitterHandleName = getParameterByName('TwitterHandleName');
new TWTR.Widget({
version: 2,
type: 'profile',
rpp: TwitterCount,
interval: 30000,
width: 272,
height: 'auto',
theme: {
shell: {
background: '#ffffff',
color: '#000000'
},
tweets: {
background: '#ffffff',
color: '#005A8C',
links: '#000000'
}
},
features: {
scrollbar: false,
loop: false,
live: false,
behavior: 'all'
}
}).render().setUser(TwitterHandleName).start();
</script>
如果我访问该页面
http://localhost/twitter.html?TwitterHandleName=billgates&TwitterCount=3
我能看到最后3条推文。
我想要的是在我的aspx页面上对此页面进行http发布。下面的代码只返回脚本标记等而不是渲染的html。我的问题是如何获取页面的渲染html?
HttpWebRequest loHttp = (HttpWebRequest)WebRequest.Create("http://localhost/twitter.html?TwitterHandleName=billgates&TwitterCount=3);
loHttp.Timeout = 30000;
loHttp.UserAgent = "Twitter";
HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();
//Encoding enc = Encoding.GetEncoding(1252); // Windows default Code Page
StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream());
string htmlCode = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();
答案 0 :(得分:1)
我知道它使用的是预构建的javascript小部件,但是你可以使用像https://github.com/danielcrenna/tweetsharp(可从NuGet获得)或http://linqtotwitter.codeplex.com/这样的Twitter包装器在服务器端移动吗?
答案 1 :(得分:0)
您可以尝试在网页上打开该网址,并使用javascript从中获取HTML。