How to iterate through list in text file using python

Question:

I want to find links in Javascript files, I have installed linkfinder, but problem i have it accepts only one link at a time.

here is what i have so far:

python linkfinder.py -i https://example.com/1.js -o results.html

but i have text file contains many urls, how do i automate all urls?

sample data in text file:

https://example.com/1.js

https://example.com/2.js

https://example.com/3.js

https://example.com/4.js

https://example.com/5.js

Asked By: tony michael

||

Answers:

A simple shell loop:

while read -r link; do
    python linkfinder.py -i "$link" -o cli
done < links.txt > results.html

-o cli writes to standard output, so all the results will be combined in a single results.html due to the output redirection of the loop.

Answered By: Barmar
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.