1

I coded a little Python programm that gets the content of files in the internet. It´s working with cURL and tkinter. The code I wrote:

from tkinter import *
import tkinter as tk
import socket
import os

root = tk.Tk()
root.title("Website Code Getter v1.8")
root.geometry("400x200")
root.resizable(False, False)

labelURL = tk.Label(root, font=("times", 15, "bold"), text="URL + /file.fileEnding [not required]").grid(row=1, column=1)
entryURL = tk.Entry(root)
entryURL.place(x=50,y=28, width=250, height=25)

def submit_url():
    global url
    url = entryURL.get()
    writeOut = os.system(f"curl {url}")

    file = open("1.txt", "w")
    file.write("Code: "+ repr(writeOut))
    file.close()

submitURL = tk.Button(root, text="Submit", command=submit_url).grid(row=3, column=3)

root.mainloop()

As shown above it´s very simple but when I try to write out the writeOut function into "1.text" in writing mode, it doesn´t work. There´s no error but in the "1.txt" there is only this:

Code: 0

In the console is the content but not in the file. I already used the function repr()

  • 1
    `writeOut = os.system(f"curl {url}")` is your problem. Per the [docs](https://docs.python.org/3/library/os.html#os.system), the value returned by `system()` is just the exit status code of the process. You need to search for a way to actually get the text output of the command rather than the exit code. There are plenty of existing solutions though so I'm not going to reinvent the wheel here. – Random Davis Jul 08 '21 at 18:04

0 Answers0