Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Net;
- using System.IO;
- using HtmlAgilityPack;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string sURL;
- sURL = "http://personer.eniro.se/resultat/Daniel Forslund Stockholm";
- WebRequest wrGETURL;
- wrGETURL = WebRequest.Create(sURL);
- Stream objStream;
- objStream = wrGETURL.GetResponse().GetResponseStream();
- StreamReader objReader = new StreamReader(objStream);
- string sLine = "";
- int i = 0;
- string full = "";
- while (sLine != null)
- {
- i++;
- sLine = objReader.ReadLine();
- if (sLine != null)
- full += sLine + Environment.NewLine;
- }
- HtmlDocument htmlDoc = new HtmlDocument();
- htmlDoc.LoadHtml(full);
- HtmlNode address = htmlDoc.DocumentNode.SelectSingleNode("//address");
- string streetAddress = htmlDoc.DocumentNode.SelectSingleNode("//span[@class='hit-street-address']").InnerText.Trim();
- string postalCode = htmlDoc.DocumentNode.SelectSingleNode("//span[@class='hit-postal-code']").InnerText.Trim();
- string addressLocality = htmlDoc.DocumentNode.SelectSingleNode("//span[@class='hit-address-locality']").InnerText.Trim();
- Console.WriteLine(streetAddress + " " + postalCode + " " + addressLocality);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement