So I have a txt file that contains several links along with other text, More specifically a list of twitter like data, (tweets that I have liked), And im trying to compile the image links specifically (t.co links) into a single txt file. So I made this script.
FileObject = open(r"like.txt","r")
word = str(FileObject)
link=[]
result = re.search('https://t.co', word)
while True:
try:
result_string = result.group(0)
link.append(result_string)
word= word.replace(result_string, "")
result = re.search('https://t.co', word)
FileObject2 = open(r"list.txt","r+")
if link(None):
print("No Image URLS Found")
else:
FileObject2.write(link + "\n")
FileObject2.close("list.txt")
result = re.search('https://t.co', word)
except: break
However upon running this, Nothing is added to list.txt. Please help.
Heres a couple of lines from the text file.
"like" :
"tweetId" : "1594749508147191808"
"fullText" : "@tragicbirdapp https://t(dot)co/LTEe5qrv0B"
"expandedUrl" : "https://twitter.com/i/web/status/1594749508147191808"
"like" :
"tweetId" : "1594880996431781890"
"fullText" : "New Drawing https://t(dot)co/kLziQSpbrT"
"expandedUrl" : "https://twitter.com/i/web/status/1594880996431781890"
```