V
V
Vladislav Khoroshev2016-01-21 04:38:45
HTML
Vladislav Khoroshev, 2016-01-21 04:38:45

How to display an image from a website by html tag?

Hello, please tell me how to display the image from the site? They gave a test task to parse the page and get a summary, the project is implemented on ASP.NET MVC, but for a start I decided to do it in WinForms, you need to use xpath . I chose this site for my experiments perm.zarplata.ru/resume.
I enter the address of the page in the TextBox, I press the button and I should post the result in the pictureBox. But it gives me a NullReferenceException. I would be grateful for any help, I don't really know how to do anything yet...
private void button1_Click(object sender, EventArgs e)
{
HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
string adress = textBox1.Text;
document.LoadHtml(adress);
HtmlNode rootNode =
document.DocumentNode.SelectSingleNode("//div[@class='job_resume_user']/a/img");
pictureBox1.ImageLocation = rootNode.Attributes["src"].Value;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
heartdevil, 2016-01-21
@davilko

Hello.
What for it on forms to do? You will only confuse yourself. Do it right away on ASP.NET MVC. Create a project boilerplate so that it runs without errors. And then HomeController you can just test your parser. And as you write, you will begin to carry it into classes.
Such a simple parser can be written using regular expressions.
Analyze the html structure of a specific resume document. Next, connect the WebClient. Download the required pages. And then you run regulars through the loaded document and pull out what you need. The same class can upload pictures. You just need to find a regular tag with the image address and then substitute this address into the DownloadFile method and upload it to yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question