Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import pandas as pd
- import json
- print ('\n***** Executando programa *****\n')
- url = 'http://www.fundamentus.com.br/resultado.php'
- print ('Acessando URL: ', url)
- myHeaders = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36',
- 'Referer': 'https://www.nseindia.com', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'}
- html = requests.get(url, headers=myHeaders).content
- df_list = pd.read_html(html, decimal= ',', thousands='.')
- df = df_list[-1]
- print ('\nGravando resultado no arquivo XLSX')
- # Create a Pandas Excel writer using XlsxWriter as the engine.
- writer = pd.ExcelWriter('fundamentus.xlsx', engine='xlsxwriter')
- # Convert the dataframe to an XlsxWriter Excel object.
- df.to_excel(writer, sheet_name='Sheet1')
- # Close the Pandas Excel writer and output the Excel file.
- writer.save()
- print ('\nFinalizando programa')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement