Mam taką oto funckję:
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create("http://www.4programmers.net");
WebReq.Timeout = 9000;
try
{
using (HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse())
{
Stream mystream = WebResp.GetResponseStream();
StreamReader mystreamreader = new StreamReader(mystream);
string myresponse = mystreamreader.ReadToEnd();
var doc = new HtmlDocument();
doc.LoadHtml(myresponse);
Console.WriteLine("---------------- >>>>>>>>>>> !");
Console.WriteLine("---------------- >>>>>>>>>>> !");
Console.WriteLine("---------------- >>>>>>>>>>> !");
Console.WriteLine("---------------- >>>>>>>>>>> Doc length !" + myresponse.Length);
int i = 0;
if (doc != null)
{
foreach (HtmlNode text in doc.DocumentNode.Descendants("//a[@href]"))
{
Console.WriteLine(text.InnerHtml);
myList.Add(new Tuple<string, string, string>(text.InnerHtml, text.InnerText, "sdgsdfgsdfg"));
i++;
}
}
Console.WriteLine("---------------- >>>>>>>>>>> !");
Console.WriteLine("---------------- >>>>>>>>>>> !");
Console.WriteLine("---------------- >>>>>>>>>>> !");
Console.WriteLine("---------------- >>>>>>>>>>> Liczba i !" + i.ToString());
// Console.WriteLine(myresponse);
}
}
catch (Exception e)
{
Toast.MakeText(this, "Bład: " + e.ToString(), ToastLength.Long).Show();
Console.WriteLine("Bład: " + e.ToString());
}
i próbuje wyciągnąć linki ze strony. Kod strony jest ściągnięty (wnioskuje po rozmiarze), ale nie mam żadnych linków. URL wrzucony na rybkę, ale probowałem z różnymi stronami...
Help !!!
Nie wiem co jest źle.
Aplikacja w emulatorze android nie wypluwa żadnych błędów
Dzieki!
Dodam jeszcze, że taki zapis:
string link = documentUrl.DocumentNode.SelectNodes("//a[@class='links-spec']")[i].Attributes["href"].Value;
jest w Xamarinie niemożliwy / niedopuszczalny.