Home > Back-end >  Random /n' appearing when I append wordlist contents to a URL
Random /n' appearing when I append wordlist contents to a URL

Time:02-20

I am trying to make a directory buster. This will:

  • take a wordlist
  • append the wordlist to the end of the url
  • make requests to the url using the wordlist (haven't got to that bit yet)

I am getting confused as when I run the code below: I get this \n' popping up. Anybody know what the issue is here ?

filename = '/Users/Desktop/requirements.txt'
nsip = 'google.com'
with open(filename, 'r') as file:
    for line in file:
        full_url = []
        full_url.append(nsip   '/'   line)
        print(full_url)

CodePudding user response:

It's likely that your text file ends in a new line. For example, here is a txt document that would work:

1
2
3

Here is what your text document most likely is:

1
2
3

As soon as you change that, your program shouldn't have an extra \n

CodePudding user response:

Every line in your file should end in a newline \n, so you may want to add something like

line2 = line.rstrip()

This will get rid of the newline character, as well as any whitespace at the end of the line.

  • Related