Importing External Data into Excel using Python

Поділитися
Вставка
  • Опубліковано 3 гру 2024
  • In this video I am going to show you how to import external data into your excel sheets. In this iteration, however, we are going to do this using web scraping with Python, BeautifulSoup and Requests. If this video was helpful please consider liking or subscribing - it would help me out a lot!
    The Code for the Script:
    import bs4
    import requests
    import openpyxl
    wb = openpyxl.load_workbook('**File Path**')
    sheet = wb['**Sheet Name**']
    r = requests.get('finance.yahoo....)
    soup = bs4.BeautifulSoup(r.text, features='html.parser')
    priceAAPL = soup.find_all('div', {'class', 'D(ib) Mend(20px)'})[0].find('span').text.replace('.', ',')
    v = sheet.cell(row=7, column=6).value = priceAAPL
    wb.save('**File Path**')

КОМЕНТАРІ •

  • @lomofatboy
    @lomofatboy Рік тому +1

    Thx

  • @vitorgomes6622
    @vitorgomes6622 2 роки тому +1

    I keep getting the variation in price instead of the value of the company. Any toughts? I've just repeated your code.

  • @paulhouseholder2868
    @paulhouseholder2868 2 роки тому +2

    What software for python are you using

    • @FinanceNik
      @FinanceNik  2 роки тому +1

      Hey Paul, you are probably referring to the IDE, which is the environment in which you code. I am using PyCharm