0

In PHP, I would like to download the CSV file behind the "Download" link on the page below but it does not have a URL associated with it, see below. Additionally, any code suggestions for uploading that file into MySQL would be helpful, see below.

This is the page I want to download from, the CSV behind the "Download" link: https://www.barchart.com/futures/quotes/Zbz20/price-history/historical

This is the HTML code of the external page, what URL can I use to download?

<div class="download-button-wrapper"> <a class="bc-btn-icon download" data-ref="historical" data-bc-download-button="ZBZ20_Price History"> <i class="bc-glyph-download"></i> <span>download</span></a> </div>

Upload Code

if ($import_b=='y') {
mysqli_query($conn, 'LOAD DATA LOCAL INFILE \'30-yearcsvout.csv\'
    INTO TABLE '.$tabletemp.'
    FIELDS TERMINATED by \',\'
    LINES TERMINATED BY \'\n\'
    IGNORE 1 LINES
    ')or die(mysqli_error());
    
    echo '...finished importing '.$file_b.' data'.' <br><br>';
}else{
    echo 'did not import '.$file_b.' <br>';
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • You have an error. [`mysqli_error()`](https://www.php.net/manual/en/mysqli.error.php) needs one argument. Please consider switching error mode on instead. [How to get the error message in MySQLi?](https://stackoverflow.com/a/22662582/1839439) – Dharman Sep 14 '20 at 17:41
  • But they have service https://www.barchart.com/ondemand "integrate market data into your website" – black blue Sep 19 '20 at 00:16

0 Answers0