HTML starter lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- pcurtis · 2020-10-07 05:00 Hi All, can anyone point me in the right direction. I want to learn about parsing a html document. In particular I want to find, a node "
" and parse all siblings of this node. See below. Quote
   
       
            Countries        
       
                                                                Afghanistan (18)
                                                                                Albania (92)
                                                                                Algeria (46)
                                                                                Andorra (10)
                                                                                ... Thanks in advance. ---------------------------------------------------------------------- trev · 2020-10-07 09:43 See fcl-xml - no idea if the comments from 2012 are up to date or still accurate. ---------------------------------------------------------------------- krolikbest · 2020-10-07 12:45 or fasthtmlparser. I do parse datas from html tables. ---------------------------------------------------------------------- pcurtis · 2020-10-07 13:03 Thanks All. ---------------------------------------------------------------------- BobDog · 2020-10-07 13:13 Here is a little html extractor, gets the html code of a web page of your choice and the equivalent text. Windows only, uses the vbscript engine. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  program WebPageToText; function  system(s:pchar):integer ; cdecl external 'msvcrt.dll' name 'system';  var g:ansistring; kill:integer=1;  procedure savefile(fname:string ;text:ansistring;killflag:integer=0); label kill ;Var T:TextFile;beginif killflag<>0 then goto kill;   AssignFile(T,fname);   {$I-}   try   Rewrite(T);   Writeln(T,text);   finally   CloseFile(T);   {$I+}   end;   kill:  if killflag<>0 then erase(T);end; procedure runscript(filename:ansiString);begin  system(pchar('cscript.exe /Nologo '+ filename) );End; beging += 'Const TriStateTrue = -1 '+chr(10);g += 'URL = InputBox("Enter (or paste) the URL to extract the Code "&vbcr&vbcr&_'+chr(10);g += '"Exemple ""https://www.freebasic.net""","Extraction of Source text and html  ", "https://forum.lazarus.freepascal.org/index.php?action=forum")'+chr(10 );g += 'If URL = "" Then WScript.Quit'+chr(10);g += 'Titre = "Extraction du Code Source de " & URL'+chr(10);g += 'Set ie = CreateObject("InternetExplorer.Application")'+chr(10);g += 'Set objFSO = CreateObject("Scripting.FileSys]"]>Blockedbject")'+chr(10);g += 'ie.Navigate(URL)'+chr(10);g += 'ie.Visible=false'+chr(10);g += 'DO WHILE ie.busy'+chr(10);g += 'LOOP'+chr(10);g += 'DataHTML = ie.document.documentElement.innerHTML'+chr(10);g += 'DataTxt = ie.document.documentElement.innerText'+chr(10);g += 'strFileHTML = "CodeSourceHTML.txt"'+chr(10);g += 'strFileTxt = "CodeSourceTxt.txt"'+chr(10);g += 'Set objHTMLFile = objFSO.OpenTextFile(strFileHTML,2,True, TriStateTrue)'+chr(10);g += 'objHTMLFile.WriteLine(DataHTML)'+chr(10);g += 'objHTMLFile.Close'+chr(10);g += 'Set objTxtFile = objFSO.OpenTextFile(strFileTxt,2,True, TriStateTrue)'+chr(10);g += 'objTxtFile.WriteLine(DataTxt)'+chr(10);g += 'objTxtFile.Close'+chr(10);g += 'ie.Quit'+chr(10);g += 'Set ie=Nothing'+chr(10);g += ' Ouvrir(strFileHTML)'+chr(10);g += ' Ouvrir(strFileTxt)'+chr(10);g += 'wscript.Quit'+chr(10);g += 'Function Ouvrir(File)'+chr(10);g += '    Set ws=CreateObject("wscript.shell")'+chr(10);g += '    ws.run "Notepad.exe "& File,1,False'+chr(10);g += 'end Function'+chr(10);   savefile('script.vbs',g) ;runscript('script.vbs'); writeln('Press enter to end . . .');readln;savefile('script.vbs','',kill);end.  Originally freebasic. It might be useful -- who knows? Auld Lang Syne ---------------------------------------------------------------------- wp · 2020-10-07 14:41 Quote from: pcurtis on October 07, 2020, 07:00:22 amIn particular I want to find, a node "
" and parse all siblings of this node. What exactly do you want to get? Do you want a list of the country names and the corresponding URLs?