Python Forum
A lot of confusion and I can't seem to solve this issue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A lot of confusion and I can't seem to solve this issue
#14
(Aug-15-2022, 09:57 AM)Calli Wrote: Now the only problem I am facing is how to output the scan result in a text file like scan.txt
You can do it like this.
import requests

with open('ip_lst1.txt') as fd,open('scan.txt', 'w') as fd_out:
    for ip in fd:
        try:
            ip = ip.strip()
            print(ip)
            response = requests.get(f"http://{ip}:9200/_cat/indices", timeout=2)
            print(response.text.strip())
            fd_out.write(f'{ip}\n{response.text.strip()}\n')
        except Exception as error:
            #print(error)
            pass
Reply


Messages In This Thread
RE: A lot of confusion and I can't seem to solve this issue - by snippsat - Aug-15-2022, 12:44 PM

Forum Jump:

User Panel Messages

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