mercredi 16 septembre 2020

problem with generating combinations of a list imported from a txt file

The code: 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?




Aucun commentaire:

Enregistrer un commentaire