Skip to content

Instantly share code, notes, and snippets.

@siumhossain
Created May 12, 2022 11:16
Show Gist options
  • Save siumhossain/6d6ffae7910ee24674689c79cb95c5c5 to your computer and use it in GitHub Desktop.
Save siumhossain/6d6ffae7910ee24674689c79cb95c5c5 to your computer and use it in GitHub Desktop.
regular expression to extract source url from iframe

extract source url and save in database

def save(self,*args,**kwargs):
        link = self.embeddedLink
        pattern = r"<iframe[^>]*src=[\"|']([^'\"]+)[\"|'][^>]*>"
        newLink = re.findall(pattern,link)[0]
        self.embeddedLink = newLink
        super().save(*args,**kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment