Python Forum
Python script - search Apache access_log.txt for all of the JavaScript (.js)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python script - search Apache access_log.txt for all of the JavaScript (.js)
#1
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

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
Reply


Messages In This Thread
Python script - search Apache access_log.txt for all of the JavaScript (.js) - by jnovak - May-03-2020, 05:19 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,877 Jun-29-2023, 11:57 AM
Last Post: gologica
  install apache-airflow[postgres,google] on Python 3.8.12 virtual env ShahajaK 1 11,234 Oct-07-2021, 03:05 PM
Last Post: Larz60+
  Apache 2.0 Licensed Python code Furkan 0 1,713 Jul-26-2021, 11:12 PM
Last Post: Furkan
Photo Integration of apache spark and Kafka on eclipse pyspark aupres 1 3,921 Feb-27-2021, 08:38 AM
Last Post: Serafim
  How to kill a bash script running as root from a python script? jc_lafleur 4 6,242 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,441 May-28-2020, 05:27 PM
Last Post: micseydel
  Package python script which has different libraries as a single executable or script tej7gandhi 1 2,748 May-11-2019, 08:12 PM
Last Post: keames
  Twitter listen script, dynamic search value? quitte74 0 1,986 Nov-01-2018, 01:09 PM
Last Post: quitte74
  Run Script written in javascript from python Scientifix 3 3,552 Apr-28-2018, 06:48 PM
Last Post: Gribouillis
  How to use python variable in javascript arun28sharma44 0 3,143 Nov-05-2017, 03:52 PM
Last Post: arun28sharma44

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020