Python Web Scraping

 import requests

import json

cookies = None;
url = 'https://www.nseindia.com/api/option-chain-indices?symbol=NIFTY'
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, '
                         'like Gecko) '
                         'Chrome/80.0.3987.149 Safari/537.36',
           'upgrade-insecure-requests': '0',
           'accept-language': 'en,gu;q=0.9,hi;q=0.8', 'accept-encoding': 'gzip, deflate, br'}

def loadnsecookie():
    baseurl = "https://www.nseindia.com/"
    session = requests.Session()
    request = session.get(baseurl, headers=headers, timeout=5)
    cookies = dict(request.cookies)


#response = session.get(url, headers=headers, timeout=5, cookies=cookies)
#print(response.json())
#r = requests.get(url, headers=headers)
expiry = "20-Oct-2022"
#print(expiry)
#exit

def fetch_oi():
    print('fetch oi called')
    r = requests.get(url, headers=headers, timeout=5, cookies=cookies).json()
    print('response received')
    #with open('oidata.json',"w") as files:
    #    files.write(json.dumps(r, indent=4, sort_keys=True))
    #print('file written')


def main():
    loadnsecookie()
    fetch_oi()

print(__name__)
if __name__ == '__main__':
    print(1)
    main()
    print(2)

Update MYSQL Definers - All at once

 show procedure status where Db <> 'DatabaseName' and Definer = 'localuser@%';

 

SET SQL_SAFE_UPDATES = 0;

update mysql.proc set definer='localuser@%' where definer='root@localhost' and db = 'DatabaseName'        ;

SET SQL_SAFE_UPDATES = 1;

 

Moment: Creating datefield with knockout

ko.bindingHandlers.datepicker = {

        init: function(elementvalueAccessorallBindingsAccessor) {

            var $el = $(element);

            

            //initialize datepicker with some optional options

            var options = allBindingsAccessor().datepickerOptions || {};

            $el.datepicker(options);

            //handle the field changing

            ko.utils.registerEventHandler(element"change"function() {

                var observable = valueAccessor();

                observable($el.datepicker("getDate"));

            });

            //handle disposal (if KO removes by the template binding)

            ko.utils.domNodeDisposal.addDisposeCallback(elementfunction() {

                $el.datepicker("destroy");

            });

        },

        update: function(elementvalueAccessor) {

            var value = ko.utils.unwrapObservable(valueAccessor()),

                $el = $(element),

                current = $el.datepicker("getDate");

            

            if (value - current !== 0) {

                $el.datepicker("setDate"value);   

            }

        }

    };

 

 

<input class="form-control" data-bind="datepicker:paidon"/>

 

self.paidon = ko.observable(new Date());

Brain Dumps

 https://free-braindumps.com/microsoft/free-pl-200-braindumps.html?p=3

Search This Blog

Link Within Related Posts Plugin for WordPress, Blogger...