본문 바로가기

Python

(7)
[Error] Npay 증권 requests import pandas as pdimport requests as rqfrom bs4 import BeautifulSoup from matplotlib import pyplot as plt url = 'https://finance.naver.com/item/sise_day.nhn?code=068270&page=1' data = rq.get(url) html = BeautifulSoup(data.content)print(html) 해당 url로 들어가면, 정상적으로 페이지가 열리는데 requests로 접속하면 서버가 파이썬 요청을 브라우저 요청으로 인식하지 않아서 "페이지를 찾을 수 없습니다"의 HTML로 돌려줌headers = { "User-Agent": "Mozilla/5.0"}data = rq..
[Error] pdr_override() module 'yfinance' has no attribute 'pdr_override' 더이상 yfinance 버전에 없는 함수라서 생긴 오류 ! 아래를 참고해보면된다.https://github.com/ranaroussi/yfinance/issues/2001 pandas data reader override function incompatible with yfinance 0.2.41 · Issue #2001 · ranaroussi/yfinanceDescribe bug latest version of yfinance breaks with pandas_datareader override(). Downgraded yfinance to 0.2.40 and it works again Simple code tha..
[Error] Webdriver_manager 오류 해결하기 module 'urllib3' has no attribute 'BaseHTTPResponse'. Did you mean: 'HTTPResponse'?이렇게 오류가 떴다!! 이건 selenium / webdriver-manager / urllib3 버전 충돌 때문이다.pip install -U selenium webdriver-manager urllib3 requests이렇게 해서 오류를 해결하였다~
[Error] Selenium 작업 중 에러가 있을 때 확인 방법 (google colab) from IPython.display import Image, displayimport oserror_screenshot_path = os.path.join(download_dir, "error_screenshot.png")if os.path.exists(error_screenshot_path): print(f"Displaying error screenshot from: {error_screenshot_path}") display(Image(filename=error_screenshot_path))else: print("Error screenshot not found.")
[Google Colab] 구글 코랩에서 Selenium 창열기 보통 코랩으로 간단하게 코드 예시를 시도해보는데, 크롤링 공부 중 구글 코랩에서는 Selenium 창이 안열린다는 걸 알게 되었다.#원래 셀레늄 창열기 코드from selenium import webdriverfrom selenium.webdriver.chrome.service import Servicefrom webdriver_manager.chrome import ChromeDriverManagerfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common.keys import Keysimport timefrom bs4 import BeautifulSoupdriver = webdriver.Chrome(service=Service(..
정적 크롤링 명언 크롤링 import requests as rqfrom bs4 import BeautifulSoupimport timetext_list = []author_list = []infor_list = []for i in range (1,100): url = f'https://quotes.toscrape.com/page/{i}/' quote = rq.get(url) quote_html = BeautifulSoup(quote.content, 'html.parser') quote_text = quote_html.select('div.quote > span.text') quote_text_list = [i.text for i in quote_text] quote_author = quote_html.se..
[Google Colab] 파일 덮어쓰기/ 파일을 저장할 때, 같은 이름이 있으면? 덮어쓰기 실험 이유 프로젝트를 진행하다가 이미지 데이터를 변형하여 쓰려고, 변형된 이미지를 구글 드라이브에 저장해서 사용하고자 했다. 이미 10,000장이 넘는 이미지가 저장되고 있었는데, 변형을 잘못하고 있다는 것을 깨달았다! 그래서 새로 고치고 다시 돌렸는데 이미 지정된 이미지가 덮어 쓰여지는 걸까 궁금했다. 만약 덮어쓰여진다면, 바로 run하면 된다. 그게 아니라면 구글 드라이브에서 해당 디렉토리를 지금까지 저장된 파일을 지우고 새로 만들어서 다시 run해야 한다. 실험 1. colab과 google drive 연동 from google.colab import drive drive.mount('/content/drive') 2. 라이브러리 import cv2 from google.colab.patc..