Here I just want to search for the keyword in the domain file without doing anything on the files. There is one key and one domain in each line. Please consider performance as there is a lot of data.
My code:
def search_keyword_domain():
# here I just want to search for the keyword in the domain file without doing anything on the files.
# There is one key and one domain in each line.
# Please consider performance as there is a lot of data
with open("result.txt", "a") as result:
result.writelines(line)
def search_keyword():
with open('domains.txt', 'r') as d:
for line in d:
line.strip()
d.close()
with open('keywords.txt', 'r') as f:
for line in f:
line = line.strip()
search_keyword_domain(line)
f.close()
if __name__ == '__main__':
search_keyword()
EXAMPLE:
strings.txt
: Note: There are 180 keywords.
google
messi
apple
domains.txt
: Note: There are 280 million domains.
google.com
ronaldovsmess.com
anapple.com
source https://stackoverflow.com/questions/73091340/searching-for-strings-in-one-txt-file-in-another-txt-file
Comments
Post a Comment