Find string in html code

Asked

Viewed 193 times

0

I need help with the following:

_Add several files ( extension .htm ), approx 20 files. _Analyze and find in the 20 files a string determined in the HTML code ( maximum string length is 20 characters).

Did you intend to do this in html with Javascript or do you prefer another language like C#? Note: My programming knowledge is low. Please your help and guidance! I thank you in advance.

  • Put the code you’ve tried to do. It helps you understand the problem you’re having.

  • So.... I haven’t started to realize it yet, which is why I wanted guidance on whether to hold with javascript or C#. Once set that I would upload my codes.

  • So I suggest to improve the text of the question because I can’t understand what is this orientation that you want.

  • apparently, it doesn’t make sense to use javascript because it runs in the browser, and you "have 20 files" to analyze. You can use C# yes, and recommend adding the HtmlAgilityPack that helps a lot. Why, if it’s only those 20 files, why not use Notepad++ and search for what you need in those files ?!

  • The reason you don’t use Notepad++ is because users ( approx 10 ) are laymen. Type need something that virtually only selects the directory to be parsed and ready.

2 answers

0

C# is a programming language that runs on the server side much more able to read and write files, has no ability to make changes on the client side, to read files in C# can use the library System.IO.File

Javascript is today has a term "variable" as its reality in programming because it was formerly used only as script that ran on the client side but today goes beyond that, can read files and create client-side files using new technologies like Html5, and there’s also its server version which is Node.js which is used as a programming language that basically does the same as C#

1. -Agora para seu caso eu ainda usaria C# por poder ler os arquivos
no servidor, e atravez de url

2. - Javascript - lado cliente ainda há umas  limitações e
provavelmente você vai econtar algumas  barreiras para fazer isso

3. - A não ser que você esta usando um servidor node.js e vá fazer a
leitura com a linguagem  Javascript no servidor em  fim

see which of the options will be more practical for its use.

There is still a possibility to make a dynamic page using c# to read the files and javascript to bring to the client side see how on ajax

  • Marcos, thank you very much for the explanation. I have never programmed in C# in my life, but I want to venture into it, despite having no idea of anything about the language. is very complex?

  • @Rodrigohackzexploitz nothing is complex just dedicate c# compared to c and C++ poussui a much cleaner syntax, over time you also get used to working with objects I started programming in c# a few 4 months before I only worked with php now c# seems pretty easy to me, I believe you will learn easily since you strive and focus

0

C# is the fastest way to read the 20 files and generate their result. Example in C#:

StreamReader file = new StreamReader(@"c:\htmls\html1.html");
string line;
line = file.ReadToEnd();
string[] x = line.Split(' ');

foreach (var item in x)
{
   if(item.Length == 20)
   {
   //faca alguma coisa
   }          
}
  • split in ' ' ?? will mess everything up in

  • I created an example as a basis

Browser other questions tagged

You are not signed in. Login or sign up in order to post.