Jump to content

HTML File list to array


Go to solution Solved by Gianni,

Recommended Posts

I want to get the file list and other information such as type (folder, file) size, date changed, ..) array displayed in html table.

I am using _StringBetwent(), i takes many hours but the code is still not giving the desired result.

Please help with another method or some fast way without having to edit the code for each different page about apche style index.

HTML Eg 5 col:

<tr><th valign="top"><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>
<tr><th colspan="5"><hr></th></tr>
<tr><td valign="top"><img src="/icons/back.gif" alt="[PARENTDIR]"></td><td><a href="/autoit3/scite/download/">Parent Directory</a></td><td>&nbsp;</td><td align="right"> - </td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="AbbrevMan.au3">AbbrevMan.au3</a></td><td align="right">2022-07-03 13:39 </td><td align="right"> 30K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/binary.gif" alt="[ ]"></td><td><a href="Au3Check.exe">Au3Check.exe</a></td><td align="right">2022-10-20 07:49 </td><td align="right">219K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/binary.gif" alt="[ ]"></td><td><a href="Au3Stripper.exe">Au3Stripper.exe</a></td><td align="right">2023-01-29 13:56 </td><td align="right">167K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="AutoIt3Wrapper.au3">AutoIt3Wrapper.au3</a></td><td align="right">2023-03-15 15:19 </td><td align="right">326K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="AutoItAutoComplete.lua">AutoItAutoComplete.lua</a></td><td align="right">2022-06-19 19:04 </td><td align="right">6.7K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="AutoItGotoDefinition.lua">AutoItGotoDefinition.lua</a></td><td align="right">2022-06-20 12:13 </td><td align="right"> 16K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="AutoItTools.lua">AutoItTools.lua</a></td><td align="right">2022-06-20 11:25 </td><td align="right"> 74K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="History.html">History.html</a></td><td align="right">2022-04-23 17:34 </td><td align="right">127K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="Scheme/">Scheme/</a></td><td align="right">2020-05-04 15:47 </td><td align="right"> - </td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td><a href="SciLexer.dll">SciLexer.dll</a></td><td align="right">2022-04-22 13:21 </td><td align="right">1.2M</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/binary.gif" alt="[ ]"></td><td><a href="SciTE.exe">SciTE.exe</a></td><td align="right">2022-03-17 18:26 </td><td align="right">1.0M</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td><a href="SciTE4AutoIt3.chm">SciTE4AutoIt3.chm</a></td><td align="right">2022-03-17 09:43 </td><td align="right">1.1M</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="SciTE5-with-DynamicFunctions/">SciTE5-with-DynamicFunctions/</a></td><td align="right">2023-04-04 19:43 </td><td align="right"> - </td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="SciTE%20Jump.au3">SciTE Jump.au3</a></td><td align="right">2022-03-14 08:51 </td><td align="right">146K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="SciTELite/">SciTELite/</a></td><td align="right">2016-03-11 13:16 </td><td align="right"> - </td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td><a href="SciteConfig.au3">SciteConfig.au3</a></td><td align="right">2022-07-03 14:03 </td><td align="right"> 69K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="SmartAutoCompleteHide.lua">SmartAutoCompleteHide.lua</a></td><td align="right">2022-06-18 18:53 </td><td align="right">3.7K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/binary.gif" alt="[ ]"></td><td><a href="Tidy.exe">Tidy.exe</a></td><td align="right">2022-11-04 21:17 </td><td align="right">184K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="UCTMan.au3">UCTMan.au3</a></td><td align="right">2022-07-03 13:39 </td><td align="right"> 28K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td><a href="au3.api">au3.api</a></td><td align="right">2022-03-06 00:52 </td><td align="right">530K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td><a href="au3.autoit3wrapper.api">au3.autoit3wrapper.api</a></td><td align="right">2022-06-15 17:19 </td><td align="right">2.3K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td><a href="autoit3wrapper.keywords.properties">autoit3wrapper.keywords.properties</a></td><td align="right">2022-06-15 17:19 </td><td align="right">2.5K</td><td>&nbsp;</td></tr>

i

Regards,
 

Link to comment
Share on other sites

Hi @Trong,

I am not sure what you want to be honest. I don't understand it. Could you please describe what you mean by:

56 minutes ago, Trong said:

without having to edit the code for each different page about apche style index.

?

Apart from this, you want a one time execution for exact this table structure or should it be a dynamical way of parsing the required information? In case you only need a one time shot, you could simple paste this content into the Browser DevTools and get your requested information by XPath. No need to script/program anything. But yes, only in case of this table (one time).

Please give me/us more information, thanks 🤝 .

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

  • Solution

assuming the html source is in a file called for example HTML_Table.html, you can use these 4 lines of code to extract the data from the table and have it returned in an array:

#include <_HtmlTable2Array.au3> ; <-- Get this here: https://www.autoitscript.com/forum/topic/167679-read-data-from-html-tables-from-raw-html-source/

Local $Source = FileRead("html_Table.html")
Local $aTableData = _HtmlTableWriteToArray($Source)

_ArrayDisplay($aTableData)

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...