Issue
I am practicing website hacking and I have this script. I want it to save each finding in one file. It currently replaces what it found with the new finding.
import requests
def request(url):
try:
return requests.get("http://" + url)
except requests.exceptions.ConnectionError:
pass
except requests.exceptions.InvalidURL:
pass
except requests.urllib3.exceptions.LocationParseError:
pass
target_url = "192.168.1.39/mutillidae/"
with open("/home/kali/PycharmProjects/websitesub/common.txt", "r") as wordlist_file:
for line in wordlist_file:
word = line.strip()
test_url = target_url + "/" + word
response = request(test_url)
if response:
with open("/home/kali/PycharmProjects/websitesub/output.txt", "w") as f:
f.write("DIR" + test_url)
print("DIR" + test_url)
Solution
this should work
with open("data1.txt", "a", encoding="utf-8") as file:
file.write(the thing you want to write)
Answered By - Chao wingching hongfingshong p
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.