
# https://www.globalsino.com/ICs/
# Web Scraping (save contents from a webpage)


from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
import time
from bs4 import BeautifulSoup
from datetime import date
import shutil


today = date.today()
d4 = today.strftime("%b-%d-%Y")

Path0 = r"C:\0Python\Stocks\StockDaily"
Path1 = r"C:\0Python\Stocks"

DestinationFolder = r"C:\0Python\Stocks\StockDaily"
sourceFile = r'C:\0Python\Stocks\Templates\CheckingNewOfStocks.csv'
DestinationFile = f"{DestinationFolder}/{d4}_Stock_Search.csv"
shutil.copy(sourceFile, DestinationFile)

ser = Service(r"C:\usr\local\bin\chromedriver.exe") 
driver = webdriver.Chrome(service=ser) 
time.sleep(2)
driver.implicitly_wait(3)
driver.maximize_window()
time.sleep(2)

driver.get("https://www.globalsino.com/EM/page4562.html")
time.sleep(3)

html = driver.page_source # ==========
# print(html)

SavedFile = f"{DestinationFolder}/{d4}_WebPage.txt"
soup = BeautifulSoup(html, "html.parser")
with open(SavedFile, "w") as file:
    file.write(str(soup))
    





