I am trying to extract data from nseindia site. It works fine in the
development environment but after I deploy to the production cloud I get
permission denied.
Output if run in local development environment:
$ php helloworld.php
UNDERLYING ,SYMBOL ,DEC-16 ,JAN-17 ,FEB-17
,MAR-17 ,JUN-17 ,SEP-17 ,NOV-16 ,DEC-17 ,JUN-18
,DEC-18 ,JUN-19 ,DEC-19 ,JUN-20 ,DEC-20 ,JUN-21
NIFTY BANK ,BANKNIFTY ,40 ,40 ,40
, , , , , , ,
, , , , ,
NIFTY 50 ,NIFTY ,75 ,75 ,75
,75 ,75 ,75 , ,75 ,75 ,75
,75 ,75 ,75 ,75 ,75
Output on running in production attached "ProductionError.jpg"
helloworld.php <?php try { //curl get function curl_get( $curl, $url,
$cookiefile) { curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl,
CURLOPT_FOLLOWLOCATION, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER,
1); curl_setopt($curl, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows
NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1" );
//curl_setopt($curl, CURLOPT_COOKIEJAR, $cookiefile); curl_setopt($curl,
CURLOPT_COOKIEFILE, $cookiefile); curl_setopt($curl,
CURLOPT_SSL_VERIFYPEER, false); $data = curl_exec($curl); return $data; }
//curl post function curl_post( $curl, $url, $cookiefile, $post) {
curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post); curl_setopt($curl,
CURLOPT_FOLLOWLOCATION, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER,
1); curl_setopt($curl, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows
NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1" );
//curl_setopt($curl, CURLOPT_COOKIEJAR, $cookiefile); curl_setopt($curl,
CURLOPT_COOKIEFILE, $cookiefile); curl_setopt($curl,
CURLOPT_SSL_VERIFYPEER, false); $data = curl_exec($curl); return $data; }
//cookie file $cookiefile = "cookie.txt"; $output = system("curl -A
,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13)
Gecko/20080311 Firefox/2.0.0.13' --url
https://www.nseindia.com/content/fo/fo_mktlots.csv");
$curl = curl_init( );
$data = curl_get( $curl,
"https://www.nseindia.com/content/fo/fo_mktlots.csv", $cookiefile);
echo $data;
$data = curl_post( $curl,
"https://www.nseindia.com/content/fo/fo_mktlots.csv", $cookiefile, "");
echo $data;
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/87434712-c091-4992-b6a5-f55886b1a01e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.