79656717

Date: 2025-06-07 06:26:43
Score: 1
Natty:
Report link

Is this what you are looking for? I have written this so it saves those strings after the url in a txt file, feel free to expand if useful.


import re

#here i copied ur links as example
js_block = r"""
{
    id: 'heic2018b',
    title: 'Galaxy NGC 2525',
    width: 3657,
    height: 3920,
    src: 'https://cdn.esahubble.org/archives/images/thumb300y/heic2018b.jpg',
    url: '/images/heic2018b/',
    potw: ''
},

{
    id: 'potw1345a',
    title: 'Antennae Galaxies reloaded',
    width: 4240,
    height: 4211,
    src: 'https://cdn.esahubble.org/archives/images/thumb300y/potw1345a.jpg',
    url: '/images/potw1345a/',
    potw: '11 November 2013'
},

{
    id: 'heic0817a',
    title: 'Magnetic monster NGC 1275',
    width: 4633,
    height: 3590,
    src: 'https://cdn.esahubble.org/archives/images/thumb300y/heic0817a.jpg',
    url: '/images/heic0817a/',
    potw: ''
},
"""

#regex to capture what's inside url: '...'
pattern = r"url\s*:\s*'([^']+)'"
matches = re.findall(pattern, js_block)

#write each match to urls.txt
with open('after_urls.txt', 'w') as out_file:
    for path in matches:
        out_file.write(path + '\n')

print(f"Wrote {len(matches)} after URLs to after_urls.txt")

cheers!

Reasons:
  • Blacklisted phrase (1): cheers
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): Is this
  • Low reputation (0.5):
Posted by: maxis112