@brcontainer/

SillyOblongAmurstarfish

PHP (Legacy)

No description

fork
loading
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$myhtml = '
<script type="text/javascript">
    var src = "https:www.site.com";
</script>
<script type="text/javascript">
    var    src    = \'https:www.site2.com\';
</script>
';

$doc = new DOMDocument;
$doc->loadHTML($myhtml);

$tags = $doc->getElementsByTagName('script');

$urls = array();

foreach ($tags as $tag) {
    if (preg_match('#var\s+src(\s+|)=(\s+|)(".*";|\'.*\';)#', $tag->nodeValue, $match)) {
        $result = preg_replace('#^["\']|["\'];$#', '', $match[3]);
        $urls[] = $result; //Adiciona ao array
    }
}

//Mostra todas urls
print_r($urls);
PHP 7.0.8 (Legacy: use the following for new features: Command-line PHP: https://repl.it/languages/php_cli PHP Web Server: https://repl.it/languages/php7