I have about 100+ files from which I need to extract certain info and copy them to separate files. They're all html files, and have html coding. File format:
<html>
<head>
...
... useless text ..
</head>
<body>
.. useless text ..
<div class="container">
<div class="another container">
<div class="heading_container">
important text
<table> ... important table contents </table>
important text
</div> //.../heading
</div> //garbage div close..
</div>/// etc etc closing divs..
<div class="clear"></div>
//above line is in all the files... so maybe the script could be written to copy all until this div (?) .
</div>
</body>
</html>
I require to copy all the text under <div class="heading_container">
...
Any idea how I could do that in a batch script? Or some html software to do it in a batch software?
I don't know much about batch scripting, but maybe the script could hold a for / while loop to copy text to a file:
variable string_start = '<div class="heading_container">';
variable string_end = '<div class="clear">';
get file("FILE_URL");
READ the file until `string_start` is reached.
output from 'string start' onwards, to a different folder with same filename.
stop output once string_end is reached.
stop read from the file.
Could this be done? I'm not too good at algorithms syntax too!
foreach($html->find('div.heading') as $e) echo $e->innertext . '<br>';
... my php file also includedinclude(php_file)
and$html=file_get_html('source_html_file)
. But I don't know how to output the php generated code to txt or html automatically. The code giving output is probablyecho $e->innertext
and I don't know how to create a loop for this to output that into txt or html files..?<div class="new_data">
and<div class="end_new_data">
or something similar? Also, please post your answer, so that I can Select it as your answer. I've copied my version of script to this page: pastebin.com/XwgsGKAF ... Directory structure here: i.imgur.com/KvQUGn2.jpg