B
B
Bundllor2021-07-11 19:29:17
HTML
Bundllor, 2021-07-11 19:29:17

How to get name from page when parsing c#?

I'm trying to parse some data from a VKontakte page. The bottom line is this: I enter the domain of any page into the box text and by clicking on the button I should display the username on the page in the label. It's just that it doesn't work. I looked in F9, and for some reason the name variable is null. Help, I've been sitting for 3 hours.60eb1bede50cc872632287.png

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace VKparser_test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void UserNameLabel_Click(object sender, EventArgs e)
        {

        }

        public void UserRefButton_Click(object sender, EventArgs e)
        {
            WebClient wb = new WebClient();
            String page = wb.DownloadString(UserRefTextBox.Text);
            //< h1 class="page_name">Имя пользователя(Павел Александров)
            String name = Regex.Match(page, @"<h1 class=""page_name"">(\w+)<span class=""image_statusstatus image_statusstatus--large"" onclick=""window.imageStatusPopup & amp; &amp; window.imageStatusPopup(event, { &quot; user_id & quot;:170274139})"">").Groups[1].Value;
            
            UserNameLabel.Text = name;
        }
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question