May-03-2020, 05:19 AM
What is expected from the python script:
1. read all the lines from given file access_log.txt and look for any presence of JavaScript files .js
2. from the lines found remove everything and keep just the "name.js"
3. remove any of duplicated rows
4. sort the lines
So far I was able to get to this stage but I do not know how to remove the duplicated rows, unwanted rows with *.css and how to sort them.
I was trying different Python functions and as well regex expression but at the moment too difficult for me.
I would appreciate any help to show me a way how my script can be updated or to show me a new solution.
Thank you in advance.
jnovak
1. read all the lines from given file access_log.txt and look for any presence of JavaScript files .js
2. from the lines found remove everything and keep just the "name.js"
3. remove any of duplicated rows
4. sort the lines
So far I was able to get to this stage but I do not know how to remove the duplicated rows, unwanted rows with *.css and how to sort them.
I was trying different Python functions and as well regex expression but at the moment too difficult for me.
I would appreciate any help to show me a way how my script can be updated or to show me a new solution.
Thank you in advance.
jnovak
kali@kali:~$ more test10.py #!/usr/bin/python import re f = open('/home/kali/Desktop/access_log.txt', "r") for line in f: if re.match("(.*).js", line): print(line.split()[6].split('/')[2])Current result of my script:
kali@kali:~$ python test10.py jquery.jshowoff.min.js jquery.js jquery.jshowoff.min.js jquery.js jshowoff.css jquery.js jquery.js jquery.jshowoff2.js jquery.jshowoff.min.js jshowoff.css jquery.js jshowoff.css jquery.jshowoff.min.js jquery.js jquery.js jquery.js jquery.js