Problem with c# script

Katana

Client
Регистрация
28.03.2021
Сообщения
84
Благодарностей
7
Баллы
8
Hello everyone,

I have a small question for a small script in c# that I can't get to work, I have a problem when I do scraping I have values with codes "&#x27" which represents an apostrophe " ' " in reality. According to my research the library "System.Net.WebUtility" that could allow me to put the right character in the collected variable.
I must be making mistakes in the script but I can't see where.
The "test" variable has been inserted in the script.
Thank you in advance to those who will help me

good day to all
 

Вложения

Katana

Client
Регистрация
28.03.2021
Сообщения
84
Благодарностей
7
Баллы
8
I had forgotten to add the return command so I added it however I still have the errors in my script.


using System;
using System.Net;

class Program
{
static void Main(string[] args)
{
// Exemple d'entité de caractère HTML
string htmlString = "project.Variables["test"].Value";

// Convertir l'entité en caractère normal
string normalString = WebUtility.HtmlDecode(htmlString);

// Afficher le résultat
Console.WriteLine(normalString);
}
return normalString;



Type Time Message
15:16:46 Compiling code of Error in action "CS1003" "Syntax error, '(' expected". [Row: 1; Column: 7]
15:16:46 Compiling code of Error in action "CS1026" ") expected". [Row: 1; Column: 13]
15:16:46 Compiling code of Error in action "CS1003" "Syntax error, '(' expected". [Row: 2; Column: 7]
15:16:46 Compiling code of Error in action "CS1026" ") expected". [Row: 2; Column: 17]
15:16:46 Compiling code of Error in action "CS1513" "} expected". [Row: 2; Column: 18]
15:16:46 Compiling code of Error in action "CS1002" "; expected". [Row: 9; Column: 49]
15:16:46 Compiling code of Error in action "CS1002" "; expected". [Row: 9; Column: 53]
15:16:46 Compiling code of Error in action "CS1519" "Invalid token 'return' in class, struct, or interface member declaration". [Row: 17; Column: 2]
15:16:46 Compiling code of Error in action "CS1519" "Invalid token ';' in class, struct, or interface member declaration". [Row: 17; Column: 21]
 

BAZAg

Client
Регистрация
08.11.2015
Сообщения
1 794
Благодарностей
2 466
Баллы
113
C#:
string text = project.Variables["test"].Value;
return System.Net.WebUtility.HtmlDecode(text);
105510
 
  • Спасибо
Реакции: Katana

Katana

Client
Регистрация
28.03.2021
Сообщения
84
Благодарностей
7
Баллы
8

BAZAg

Client
Регистрация
08.11.2015
Сообщения
1 794
Благодарностей
2 466
Баллы
113

Katana

Client
Регистрация
28.03.2021
Сообщения
84
Благодарностей
7
Баллы
8
Thank you very much, I don't have any more errors with your script but I don't understand because the final value remains unchanged, was I in the wrong library?
The value returned remains unchanged
 

Вложения

BAZAg

Client
Регистрация
08.11.2015
Сообщения
1 794
Благодарностей
2 466
Баллы
113
Thank you very much, I don't have any more errors with your script but I don't understand because the final value remains unchanged, was I in the wrong library?
The value returned remains unchanged
105521



I adapted the code, it should run correctly.
To return a value to a variable, you need to specify it.
But, I don't know if the WebUtility method does the transformation you need - I thought you know what it does, but don't know how to run it in Zennoposter.
 
  • Спасибо
Реакции: Katana

Katana

Client
Регистрация
28.03.2021
Сообщения
84
Благодарностей
7
Баллы
8

Learn2023

Пользователь
Регистрация
18.03.2023
Сообщения
71
Благодарностей
1
Баллы
8

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)