Home > Back-end >  How to iterate through list in text file using python
How to iterate through list in text file using python

Time:07-27

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

CodePudding user response:

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.

  • Related