0

現在のページのすべてのリンクを取得し、必要なリンクを探してから、このリンクのアンカー (「a」の開始タグと終了タグの間のテキスト) を取得したいと考えています。「obj.GetAttribute("innerText")」を使用しようとしましたが、空の文字列が返されます。

WebClient client = new WebClient();
string htmlCode = client.DownloadString("http://mysite1.com");

CQ cq = CQ.Create(htmlCode);
foreach (IDomObject obj in cq.Find("a")){
 string href = obj.GetAttribute("href");
   if (href.IndexOf("mysite2.com") != -1){
      //get the anchor of this link
   }
 }
4

1 に答える 1