using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel.Syndication;
using System.Xml;
namespace TwitterAnalysis
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
int pagenum = 1;
while (true)
{
string url = "http://search.twitter.com/search.atom?q=" + textBox3.Text + "&rpp=100&page=" + pagenum + "&show_user=true";
SyndicationFeed feed = SyndicationFeed.Load(XmlReader.Create(url));
var items = from item in feed.Items
orderby item.PublishDate descending
select new { Author = item.Authors[0].Name, Date = item.PublishDate.Date., Content = item.Title.Text };
int count = 0;
foreach (var item in items)
{
ListViewItem i = new ListViewItem(item.Author);
i.SubItems.Add(item.Date);
i.SubItems.Add(item.Content);
listView1.Items.Add(i);
count++;
}
if (count < 100)
break;
else
pagenum++;
}
}
}
}
Twittr上的REST API调用
最新推荐文章于 2023-12-03 10:58:42 发布