I have made a webscraping program using Selenium (Chrome webdriver) and BeautifulSoup with a simple GUI using Tkinter. It works as expected when I am running it with Thonny. However, after making the .exe file with pyinstaller, I got error below:
Exception in Tkinter callback
Traceback (most recent call last):
File "lib-tk\Tkinter.py", line 1547, in __call__
File "app_jun.py", line 20, in click
TypeError: __init__() got an unexpected keyword argument 'service'
Below is the command that I used to make .exe file in pyinstaller:
pyinstaller.exe --onedir app_jun.py
and here's my main code:
from tkinter import *
from bs4 import BeautifulSoup
from datetime import date
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
ChromeService = Service('C:\Program Files (x86)\chromedriver.exe')
url='https://bibit.id/reksadana.html'
reksadana=[]
x=[]
temp=[]
root = Tk()
def click():
temp=[]
browser = webdriver.Chrome(service = ChromeService)
browser.set_window_position(-10000,0)
browser.get(url)
time.sleep(5)
browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(5)
html_source_code = browser.execute_script("return document.body.innerHTML;")
soup = BeautifulSoup(html_source_code, 'html.parser')
browser.quit()
table = soup.find('tbody')
tbody = table.find_all('tr', class_='row-table')
for data in tbody:
td = data.find_all('td')
for data in td:
x.append(data.text)
for i in x:
temp.append(i)
if len(temp) == 13:
reksadana.append(temp)
temp=[]
today = str(date.today())
with open('Reksadana'+today+'.txt', 'w') as f:
for i in reksadana:
for q in i:
f.write(str(q)+';')
f.write('\n')
label = Label(root, text='Saving Reksadana ')
label.pack()
button = Button(root, text='Start Scraping!', command=click)
button.pack()
root.mainloop()
Does anybody have any insight as to why this is happening? Sorry for my bad English btw