-1

The app that i created looks up in a list of websites and returns a full match if the value of the input i entered matches fully any of the elements in the list the app prints that a full match found, or if the inputed value doesn't match ,the app prints that the input you entered didn't match any of the elements in the list, or if the input partially matches any of the elements in the list the app prints that a partial match is found.The thing is that i wrote the app in a way so when i run it an input field appears in order to enter the 'words' or 'links' that i want to see if they match any in the existing list, but instead of having this input field appeared i want to enter the value of the input directly when i run the app, for example:

python3 app.py www.virus.com

and then the app make all the look up in the list and print the result, wether there's a full match, a partial match or no match.

listOfSites = ( "www.phishingsite.com", 
            "www.virus.net.org/clickme", 
            "zxcmalware.com", 
            "trojan.badsite.org", 
            "www.tgby.com/ratlink"
        )
while stop == False:
    # Input Variable
    enter_site = str(input('Enter your URL here: '))
    # Conditional list Comprehension
    matching = [s for s in listOfSites if enter_site in s]
    reply = False
    if enter_site in listOfSites:
        reply = False
        print(f'Full match for {enter_site}')
    elif matching:
        reply = False
        print(f'Partial match found for {matching}')
    elif enter_site not in listOfSites:
        reply = False
        print(f'No match found for {enter_site}')
    while reply == False:
        go_on = str(input('Keep on searching? (y/n): '))
        if go_on.lower() =='n':
            stop=True
            reply=True
        elif go_on.lower() == 'y':
            reply =True
            stop = False
        elif go_on.lower() != 'n' and go_on.lower() != 'y':
            plus = 'Type y for yes or n for no'
            print(plus + go_on)
print('You left the search')

I hope i was clear

Thank you in advance!

  • Does this answer your question? [How do I access command line arguments in Python?](https://stackoverflow.com/questions/4033723/how-do-i-access-command-line-arguments-in-python) – SDS0 Apr 08 '21 at 10:52
  • 2
    Does this answer your question? [How to read/process command line arguments?](https://stackoverflow.com/questions/1009860/how-to-read-process-command-line-arguments) – Craicerjack Apr 08 '21 at 10:52

1 Answers1

0

When you run a program in the command line you can access these arguments by using the sys module.

sys.argv contains all arguments, in your case calling 'python3 app.py www.virus.com' it looks like this ['app.py', 'www.virus.com']

Here the URL is in sys.argv[1].

JMad
  • 112
  • 1
  • 7