0

When I run the code below, I get a 307 Error as the return

if(isset($_GET['tag'])){
    $tag = strtoupper($_GET['tag']);
    $curl = curl_init("https://www.bloomberg.com/quote/".strtoupper($tag).":US");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $page = curl_exec($curl);

    if(curl_errno($curl)) // check for execution errors
    {
        echo 'Scraper error: ' . curl_error($curl);
        exit;
        echo '<script>alert("")</script>';
    }
    curl_close($curl);
    $regex = '/<span class="priceText__1853e8a5">(.*?)<\/span>/';
    echo $page;
    if ( preg_match($regex, $page, $list) ){
        $price = $list[0];
        $regex = '/<div class="value__b93f12ea">(.*?)<\/div>/';
        preg_match($regex, $page, $list);
        echo '<script>alert("'.$price.'")</script>';
    }
    include "fetch.php";
}

When I went to the website with my browser, I can see the page! Can someone please help me fix and understand what is going on? Thanks!

Chris
  • 4,672
  • 13
  • 52
  • 93
Joe Jameson
  • 79
  • 1
  • 12

0 Answers0