knowledge_div = dash_table.DataTable(
style_cell={
'whiteSpace': 'pre',
'height': 'auto',
'overflow': 'hidden',
'backgroundColor': 'rgb(50, 50, 50)',
'color': 'white'
},
id='table',
columns=[{"name": i, "id": i} for i in knowledge.columns],
data=knowledge.to_dict('records'),
style_as_list_view=True,
style_header={'backgroundColor': 'rgb(30, 30, 30)', 'fontWeight': 'bold', 'textAlign': 'center'},
style_data_conditional=[{'if': {'row_index': 'odd'}, 'backgroundColor': 'rgb(40, 40, 40)'}]
)
import requests
URL = 'https://ycharts.com/login?next=/companies/AAPL/market_cap'
client = requests.session()
# Retrieve the CSRF token first
client.get(URL) # sets cookie
if 'csrftoken' in client.cookies:
# Django 1.6 and up
csrftoken = client.cookies['csrftoken']
else:
# older versions
csrftoken = client.cookies['csrf']
login_data = dict(username=login, password=password, csrfmiddlewaretoken=csrftoken)
r = client.post(URL, data=login_data, headers=dict(Referer=URL))
driver = webdriver.Firefox(executable_path=r'C:\dr\geckodriver.exe')
driver.get(url)
for i in driver.get_cookies():
if i['name'] == 'csrftoken':
csrftoken = i['value']
elif i['name'] == 'csrf':
csrftoken = i['value']
driver.get(url)
s_username = driver.find_element_by_name('username')
s_password = driver.find_element_by_name('password')
s_continue = driver.find_element_by_css_selector('.btn-block')
s_username.send_keys(login)
s_password.send_keys(password)
s_continue.click()
def on_message(ws, message):
json.dump(message, open('Binance_websoket.json','a'))
import csv
with open('names.csv', 'w', newline='') as csvfile:
fieldnames = ['first_name', 'last_name']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
writer.writerow({'first_name': 'Baked', 'last_name': 'Beans'})
writer.writerow({'first_name': 'Lovely', 'last_name': 'Spam'})
writer.writerow({'first_name': 'Wonderful', 'last_name': 'Spam'})