I'm writing lots of urls into a txt file like this inside my script with a loop:
fwrite = open('visited.txt', 'a')
fwrite.write('\n{0}'.format(url))
fwrite.close()
Then when i re-run later i don't want to process visited links so i do this:(visit is a list of new/old urls)
for x in visit:
if x in open('visited.txt').read().lstrip('\r\n'):
visit.remove(x)
else:
continue
But this always skips half of the lines. If there are 1000 urls, it removes only 500 of it. tried both lstrip
/rtsrip
with \n
and \r\n
but couldn't manage it