如何检索其他网站数据? [英] How to retrieve other site data?
本文介绍了如何检索其他网站数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试为我的博客检索CodeProject文章数据。我有几个问题。
1)是合法的吗?
2)安全吗?
3)我想获得主页的最新文章部分。但是,我只想要文章和文章的链接。可能吗?
4)如果安全合法,我怎么能这样做?
I am trying to retrieve CodeProject article data for my blog. I have a few questions.
1) Is is legal?
2) Is it safe?
3) I want to get 'Latest Articles' part of the main page. However, I just want the ttile and the link of article. Is it possible?
4) How can i do that if safe and legal?
string url = "http://www.codeproject.com/";
try
{
HttpWebRequest istek = (HttpWebRequest)WebRequest.Create(url);
istek.AllowAutoRedirect = true;
istek.Credentials = CredentialCache.DefaultCredentials;
istek.Proxy = WebRequest.GetSystemWebProxy();
istek.UseDefaultCredentials = true;
istek.UserAgent = "CodeProject Bot";
HttpWebResponse yanit = (HttpWebResponse)istek.GetResponse();
StreamReader okuyucu = new StreamReader(yanit.GetResponseStream());
string gelenKaynak = okuyucu.ReadToEnd();
int IcerikBaslangicIndex = gelenKaynak.IndexOf("<div id=" + '"' + "arttypes" + '"' + ">") + 30;
int IcerikBitisIndex = gelenKaynak.Substring(IcerikBaslangicIndex).IndexOf("</div>");
string final = System.Web.HttpUtility.HtmlDecode(gelenKaynak.Substring(IcerikBaslangicIndex, IcerikBitisIndex)).ToString();
string[] sonuc;
string[] stringSeparators = new string[] { "<div class=" + '"' + "row" + '"' + ">" };
sonuc = final.Split(stringSeparators, StringSplitOptions.None);
return sonuc;
}
catch (Exception)
{
throw;
}
我完全得到了代码项目的无意义部分。我错过了什么?
I am getting totaly nonsense part of codeproject. What am I missing?
推荐答案
您需要在文章写作或Bugs&Sugs论坛中发布您的问题,以便其中一位网站管理员可以建议您是否被允许要做到这一点。
You need to post your question in the Article Writing or Bugs & Sugs forum, so one of the site administrators can advise whether you are allowed to do this.
你好,
除了理查兹的建议,如果你收到网站所有者的澄清,他们是好的,你可以看一下 CodeProject API [ ^ ]
...特别是 GetArticles方法 [ ^ ] ......因为这是为了公开CodePorject文章/博客/提示。
...希望它有帮助
Hi,
In addition to Richards advice, if you receive clarification from the site owners that they are ok with you doing this, you could have a look at the CodeProject API[^]
... specifically the GetArticles Method[^] ... as this is provided to expose CodePorject Articles/Blogs/Tips.
... hope it helps
这篇关于如何检索其他网站数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文