Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to iterate through list in text file using python

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading