0

The code:

def title():

    print("Importing keywords...")
    sleep(0.5)
    file = open('keywords.txt', 'r')
    keywords = file.readlines()
    file.close()

    print("Keywords imported")
    sleep(0.5)
    file = open('keywords.txt', 'r')
    keywords = file.readlines()
    sleep(0.5)
    file.close()



    kw = keywords
    param = ['oid', 'ap', 'utm_source', 'PageName', 'div', 'ID']
    pageform = ['php', 'asp', 'aspx', 'htm', 'html']

    for ln in [f"    {k} //{prm}= .{pf}?" for k in kw for pf in pageform for prm in param]:
        print(ln)

output:

all the possible conbinations and thats but only the ones generated from with keyword 1 look as they should look like for example:

keyword1 //oid= .php?
keyword1 //ap= .php?
keyword1 //utm_source= .php?
keyword1 //PageName= .php?
keyword1 //div= .php?
keyword1 //ID= .php?
keyword1 //oid= .asp?

but the one with keyword 2 is generated like this:

 //oid= .php?
    keyword2
 //ap= .php?
    keyword2
 //utm_source= .php?
    keyword2
 //PageName= .php?
    keyword2
 //div= .php?
    keyword2
 //ID= .php?
    keyword2
 //oid= .asp?
    keyword2
 //ap= .asp?
    keyword2
 //utm_source= .asp?
    keyword2
 //PageName= .asp?

And the list of keywords imported from a txt file in this format:

keyowrd1
keyword2

Can somebody help?

Sam Mason
  • 15,216
  • 1
  • 41
  • 60
valakise
  • 3
  • 1
  • sounds like you are seeing the effects of a newline character hiding in there – Chris Sep 16 '20 at 19:00
  • where? i havent put \n anywhere – valakise Sep 16 '20 at 19:27
  • or you mean in the txt file? i want to be able to just paste an appending list of keywords there and import them as a list and when i generate combination everything should be in one line but i dont know what i did wrong – valakise Sep 16 '20 at 19:28
  • if you hit enter after a line in a text file, it will have a newline character at the end, even if you don't see it - how else would notepad know there's a new line? – Chris Sep 16 '20 at 19:29
  • yes and thats clear now but i dont know how can fix the main problem im having here, can you help please? – valakise Sep 16 '20 at 19:34
  • https://stackoverflow.com/questions/15233340/getting-rid-of-n-when-using-readlines – Chris Sep 16 '20 at 19:41

0 Answers0