本文介绍了从c#(twitter)网页获取所有评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! Hai, 我已经开发了一个网页来获取Twitter的所有评论。使用下面的代码我已成功实现。这里的问题是,这段代码只提取几条评论。但是当我们在Twitter上搜索意味着它显示了超过十万的评论。在我们滚动页面时,在twitter中自动更新评论。但是在c#中我们无法实现它。我至少需要获取10000条评论。 你能帮助我吗??? protected void Button1_Click( object sender,EventArgs e) { if (!string.IsNullOrEmpty(TextWeburl.Text)) { 尝试 { string url = 串 .Empty; url = https://twitter.com/search?q= + TextWeburl .Text + & src = typd; var getHtmlDoc = new HtmlWeb(); var document = getHtmlDoc.Load(url); var tags = document.DocumentNode.SelectNodes( // p 的); if (tags!= null ) { foreach ( var sitetag in tags) { // txtFull.Text + = sitetag.InnerText +\ n; if (sitetag.Attributes.Count!= 0 ) { if (sitetag.Attributes [ Class ]。值== js-tweet-text tweet-text) txtFull.Text + = sitetag.InnerText + \ n + \\\; } } } } catch (FileNotFoundException ex) { throw ex; } catch (SyntaxErrorException ex) { throw ex; } } } 解决方案 我没有使用Twitter API,但我是确保在用户滚动时从服务器加载注释。 AFAIK,你不能通过像方法一样抓取那些评论。您可能需要向twitter发送请求或查看其API以获取可以提供帮助的特定方法。 Hai, I have developed a web page to get all comments from twitter. Using below code i have achieved successfully. Here problem is, This code fetch few comments only. but when we search in twitter means it shows more than a lakhs comments. in twitter automatically updates the comments when we scroll the page. but in c# we can not achieve it. i need to fetch 10000 comments at least.Can you help me anyone???protected void Button1_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(TextWeburl.Text)) { try { string url = string.Empty; url = "https://twitter.com/search?q=" + TextWeburl.Text + "&src=typd"; var getHtmlDoc = new HtmlWeb(); var document = getHtmlDoc.Load(url); var tags = document.DocumentNode.SelectNodes("//p"); if (tags != null) { foreach (var sitetag in tags) { //txtFull.Text += sitetag.InnerText + "\n"; if (sitetag.Attributes.Count != 0) { if (sitetag.Attributes["Class"].Value == "js-tweet-text tweet-text") txtFull.Text += sitetag.InnerText + "\n" + "\n"; } } } } catch (FileNotFoundException ex) { throw ex; } catch (SyntaxErrorException ex) { throw ex; } } } 解决方案 I have not worked with Twitter APIs, but I am certain that it loads comments from the server when user scrolls. AFAIK, you can not get those commenting via scraping like methods. You probably need to send requests to twitter or look into their APIs for a specific method that can help. 这篇关于从c#(twitter)网页获取所有评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-19 17:22