-1

Here is my code:

import urllib
import re
import requests
import httplib
import socket
from colorama import *
from time import gmtime, strftime
  def hell():
    hcon = raw_input(Fore.RED + Style.BRIGHT + "Website: ")
    r = requests.get("http://" + hcon + "/phpmyadmin")
    r2 = requests.get("http://" + hcon + "/pma")
    if r.status_code == 404:
     print(strftime("[%H:%M:%S]", gmtime()) + " /phpmyadmin/ not found!") 
    elif r: 
     print(strftime("[%H:%M:%S]", gmtime()) + " /phpmyadmin/ successfully found! %s /phpmyadmin") % (hcon)
    elif r2:
     print(strftime("[%H:%M:%S]", gmtime()) + " /phpmyadmin/ successfully found! %s /pma") % (hcon)
    else:
     print(strftime("[%H:%M:%S]", gmtime()) + " nothing found, sorry! try another website.")

hell()

As you can see, If the page /phpmyadmin or /pma exists on the selected website it will output that it was successfully found, If not it will say "nothing found etc etc.."

But I get this error: unindent does not match outer indentation level, I have never occurred this error in any of my previous python scripts.

I've tried to fix the indentation as much as I can but I don't think that will solve it, Can someone help?

Dave Stallberg
  • 1,503
  • 2
  • 13
  • 13
  • 1
    It looks like you've modified the code; when I paste it and try to run it locally I instead get "unexpected indent" on the "def hell()" line. Naturally, to fix that you need to move the def block back a couple of spaces, as the answers suggest. However, the error you describe is different, and typically shows up when you have a line indented by X spaces, then some indented by X+Y+Z spaces, and finally one indented by X+Y spaces. Whenever you dedent, Python requires you to go back to the same level as one of your previous ones. – Walter Mundt Aug 01 '13 at 21:32
  • I did that but I copied and pasted some of my code, not all. I did do that but the problem is I still get the error @WalterMundt – Dave Stallberg Aug 01 '13 at 21:33

5 Answers5

2

In your case, the hell method definition must be at the root indentation level.

Gustavo Barbosa
  • 1,340
  • 1
  • 17
  • 27
0

def hell() and everything below should have 1 indentation less.

zubergu
  • 3,646
  • 3
  • 25
  • 38
0

Copied from a comment since this is now answer-ish.

So the code you pasted is incomplete, so I can't give a direct fix for the error you're getting.

Your error typically shows up when you have a line indented by X spaces, then some indented by X+Y+Z spaces, and finally one indented by X+Y spaces. Whenever you dedent, Python requires you to go back to the same level as one of your previous ones. For example:

def foo():
    print "hi!"
  return 42

Notice that the return statement's indent is 2 spaces, but no previous line is indented by 2 spaces. This isn't allowed, and it needs to be indented out to 4 spaces, or the print statement moved back to line up at 2 spaces in.

Walter Mundt
  • 24,753
  • 5
  • 53
  • 61
0

You have mixed spaces and tabs. Try opening your code in Notepad or something with an 8-space indentation level and see what it looks like. It definitely doesn't match what you've posted, or you'd be getting "unexpected indent" errors rather than unindent problems.

user2357112
  • 260,549
  • 28
  • 431
  • 505
0

You need to fix the indentation of def hell():

import urllib
import re
import requests
import httplib
import socket
from colorama import *
from time import gmtime, strftime

def hell():
    hcon = raw_input(Fore.RED + Style.BRIGHT + "Website: ")
    r = requests.get("http://" + hcon + "/phpmyadmin")
    r2 = requests.get("http://" + hcon + "/pma")
    if r.status_code == 404:
        print(strftime("[%H:%M:%S]", gmtime()) + " /phpmyadmin/ not found!") 
    elif r: 
        print(strftime("[%H:%M:%S]", gmtime()) + " /phpmyadmin/ successfully found! %s /phpmyadmin") % (hcon)
    elif r2:
        print(strftime("[%H:%M:%S]", gmtime()) + " /phpmyadmin/ successfully found! %s /pma") % (hcon)
    else:
        print(strftime("[%H:%M:%S]", gmtime()) + " nothing found, sorry! try another website.")

hell()
jh314
  • 27,144
  • 16
  • 62
  • 82