묻고 답해요
164만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결[신규 개정판] 이것이 진짜 크롤링이다 - 기본편
페이지 번호가 이상하게 뜹니다.
안녕하세요. 1페이지, 2페이지 이런 식으로 나타나야 하는데, 11페이지, 21페이지 이런 식으로 뜨게 됩니다. 어떤 점이 잘못 된 걸까요?이전에 pyautogui 실행이 잘 안 되서 pylance를 다시 설치했는데 그 이후론 하늘색으로 보이던 글자들이 흰색으로 변하게 되었습니다. 혹시 이 점이 어떤 연관이 있는 걸까요?
-
미해결[신규 개정판] 이것이 진짜 크롤링이다 - 실전편 (인공지능 수익화)
부동산 매물 강좌 관련 문의
안녕하세요! 강사님 강의를 끝까지 다 수강하였습니다. 너무 도움이 많이 되었습니다. 감사합니다.부동산 매물 강의에 대한 공지를 보고 메일로 문의 드렸는데 아직 피드백이 오지 않아 이렇게 질문글로 문의를 드리게 되었습니다!메일 문의 한 번만 확인 부탁드립니다. 감사합니다!
-
미해결일잘하는 마케터, MD에게 꼭 필요한 파이썬 데이터 분석
에러 질문드립니다.
# 셀레니움 module import # from selenium import webdriver ################################################################################################################################################################ # 2023.06.08 셀레니움 버전 업데이트로 인해 사용불가 ################################################################################################################################################################ # 2023.05.08 selenium webdriver 사용방법 변경 # from selenium.webdriver.common.by import By # from selenium import webdriver # import time # from time import sleep # from bs4 import BeautifulSoup # from selenium.webdriver.common.keys import Keys # import requests # import re # import os # # Dataframe # import pandas as pd # df = pd.DataFrame(columns=['idx','star','review']) # chrome_options = webdriver.ChromeOptions() # chrome_options.add_argument('--headless') # chrome_options.add_argument('--no-sandbox') # chrome_options.add_argument('disable-dev-shm-usage') # chrome_options.add_argument("user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36") # driver = webdriver.Chrome('chromedriver', options=chrome_options) ################################################################################################################################################################ # 2023.07.09 셀레니움 버전업으로 인한 코드 변경 ################################################################################################################################################################ from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By import time from time import sleep from bs4 import BeautifulSoup import requests import re import os # Dataframe import pandas as pd df = pd.DataFrame(columns=['idx','star','review']) service = Service(executable_path="chromedriver") options = webdriver.ChromeOptions() options.add_argument('--headless') options.add_argument('--no-sandbox') driver = webdriver.Chrome(service=service, options=options)안녕하세요. 해당 부분 다음과 같이 오류가 나오는데 어떻게 하면 좋을까요?NoSuchDriverException Traceback (most recent call last) <ipython-input-6-e1d24ca4db7f> in <cell line: 48>() 46 options.add_argument('--headless') 47 options.add_argument('--no-sandbox') ---> 48 driver = webdriver.Chrome(service=service, options=options) 2 frames/usr/local/lib/python3.10/dist-packages/selenium/webdriver/common/driver_finder.py in get_path(service, options) 42 43 if path is None or not Path(path).is_file(): ---> 44 raise NoSuchDriverException(f"Unable to locate or obtain driver for {options.capabilities['browserName']}") 45 46 return path NoSuchDriverException: Message: Unable to locate or obtain driver for chrome; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
-
미해결[신규 개정판] 이것이 진짜 크롤링이다 - 기본편
네이버 쇼핑몰 메뉴 & 검색창
a.nav.shop해도 쇼핑으로 이동안되서 찾아보니까 link_service로 되어있어서 수정했는데 수정하면 이메일 창으로 이동되요 ㅠㅠ그리고 검색창 클래스 부분도 맞게 하는데 input._ac_input으로 해서 작성해도 오류나와요 ㅠㅠ
-
미해결[신규 개정판] 이것이 진짜 크롤링이다 - 기본편
chromedriver 설치가 안돼요
크롬 버전이 115.0.5790.110인 경우 설치를 어떻게 해야하는지 모르겠습니다.....status가 X라고 표시돼있는데 어떻게 설치해야할까요....?
-
미해결[리뉴얼] 파이썬입문과 크롤링기초 부트캠프 [파이썬, 웹, 데이터 이해 기본까지] (업데이트)
링크가 바꼈는지 댓글이 안뜨네요
https://davelee-fun.github.io/trial/board/news.html 강의에서는 댓글까지 크롤링을 하셔서 따라해볼려하니까 링크에 댓글이 안떠서 불가능하네요..확인부탁드립니다.
-
미해결[리뉴얼] 파이썬입문과 크롤링기초 부트캠프 [파이썬, 웹, 데이터 이해 기본까지] (업데이트)
12분 9초 질문드립니다.
먼저 좋은 강의 제공해주신 강사님께 감사의 말씀 드립니디.12분 9초 질문드립니다. 강의에서 'NoneType' object has no attribute 'get_text' 해당 오류가 나온 이유가 list_item안에 단순히 뭐가 있냐 없냐를 따지는게 아니라 list_item안에 뭐가 있더라도 span subject_fixed 가 없으면 해당 오류가 뜨는거아닌가요? 수업시간에 강사님께서 말씀주신걸로 이해해 보면 list_item에 span subject_fixed가 아닌 어떤것이 있기만 하면 넘어가는 식으로 하셔서 헷갈려서 문의드립니다 ㅠ
-
해결됨일잘하는 마케터, MD에게 꼭 필요한 파이썬 데이터 분석
19강 프로펫 실습 시 에러
안녕하세요 :) 수업 감사드립니다.16강 공유해주신 소스코드 따라 실습하던 중, 제일 첫 번째 코드에서부터 에러가 나서 문의 드립니다. fbprophet 이라는 모듈명에 무슨 문제가 있는 것일까요?입력코드import pandas as pd from fbprophet import Prophet from matplotlib import pyplot from google.colab import drive drive.mount('/content/drive')에러메시지--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-4-3acd5be7f1b8> in <cell line: 2>() 1 import pandas as pd ----> 2 from fbprophet import Prophet # 매출예측 lib 3 from matplotlib import pyplot 4 5 from google.colab import drive ModuleNotFoundError: No module named 'fbprophet' --------------------------------------------------------------------------- NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt. To view examples of installing some common dependencies, click the "Open Examples" button below. ---------------------------------------------------------------------------
-
미해결[신규 개정판] 이것이 진짜 크롤링이다 - 기본편
네이버쇼핑 크롤링 과정 오류 질문
계속 이런 오류가 나오와요 크롬드라이브 해당 버젼에 맞게 설치했는데도 ㅠㅠ처음에 코딩 잘못입력한줄 알았는데 뭐가 문제인지 몇시간동안 반복하고있어서 글올렸습니다 도와주세요 ㅠㅠ
-
미해결[리뉴얼] 파이썬입문과 크롤링기초 부트캠프 [파이썬, 웹, 데이터 이해 기본까지] (업데이트)
Error 관련 질문드립니다.
json 코드 입력했더니 이런 Error 가 뜨는데 왜 그런지 알수 있을까요..?
-
미해결[신규 개정판] 이것이 진짜 크롤링이다 - 실전편 (인공지능 수익화)
크롤링 시 다양한 태그들에 대한 대처
안녕하세요. 네이버 지도 크롤링 강의를 듣다 궁금한 점이 생겨 질문드립니다! 네이버 지도에서 [강남역 맛집, 홍대 술집, 이태원 카페] 와 같이 검색하여 나타나는 CSS선택자는 li.UEzoS.rTjJo 와 같이 선택하면 잘 선택이 되지만,[청담 미용실] 과 같이 선택하면 다른 CSS 선택자를 선택해야 합니다.이럴 경우 어떻게 대처를 하면 좋을지에 대해 질문을 남겨봅니다. 항상 강의 잘 듣고 있습니다. 감사합니다!
-
미해결[리뉴얼] 파이썬입문과 크롤링기초 부트캠프 [파이썬, 웹, 데이터 이해 기본까지] (업데이트)
크로링 패턴에서 필요한 부분을 지정하는 방법
- 섹션 3 크롤링 패턴 관련 질문이 있습니다. 변수.find() 을 이용하여 원하는 부분을 찾는다고 했는데, 이때 find의 괄호 안에는 태그의 이름만 들어가는 게 맞나요?
-
미해결내 업무를 대신 할 파이썬(Python) 웹크롤링 & 자동화 (feat. 주식, 부동산 데이터 / 인스타그램)
버전 관련 질문
안녕하세요. 파이썬 및 판다스의 강의 촬영 날짜 기준 버전과 현재 버전이 다른데 문제 없이 강의를 따라갈 수 있을까요??
-
미해결[신규 개정판] 이것이 진짜 크롤링이다 - 실전편 (인공지능 수익화)
네이버 뉴스본문 가지고 오기도 되고 연예뉴스도 되는데 스포츠 뉴만 안되네요?
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.AttributeError: 'NoneType' object has no attribute 'text'이 오류가 계속 나오네요연예뉴스 복사한후 바로 코드를 다시 썼는데도 안되네요 ㅠㅠimport requests from bs4 import BeautifulSoup import time response = requests.get("https://search.naver.com/search.naver?sm=tab_sug.top&where=news&query=%EC%86%90%ED%9D%A5%EB%AF%BC&oquery=%EB%B8%94%EB%9E%99%ED%95%91%ED%81%AC&tqi=iK4yElprvmZss69Ig8Nssssss1w-042517&acq=thsgmd&acr=1&qdt=0") html = response.text soup = BeautifulSoup(html,'html.parser') articles = soup.select("div.info_group") for article in articles: links = article.select("a.info") if len(links) >= 2: url = links[1].attrs["href"] response = requests.get(url,headers={'User-agent':'Mozila/5.0'}) html = response.text soup = BeautifulSoup(html,'html.parser') # 만약 연예 뉴스라면 if "entertain" in response.url: title = soup.select_one(".end_tit") content = soup.select_one ("#articeBody") elif "storts" in response.url: title = soup.select_one("h4.title") content = soup.select_one ("#newsEndContents") # 본문 내용안애 불필요한 div삭제 divs = content.select("div") for div in divs: div.decompose() paragraphs = content.select("p") for p in paragraphs: p.decompose() else: title = soup.select_one("#artcleTitle") content = soup.select_one("#areicleBodyContents") print("============링크=========\n", url) print("============제목=========\n", title.text.strip()) print("============본문=========\n", content.text.strip()) time.sleep(0.3)
-
미해결실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용
셀레니움 꺼짐 현상
from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_experimental_option("detach", True) driver = webdriver.Chrome(options=options) url = "https://naver.com" driver.get(url) 위 처럼 작성을 했는데 계속 꺼집니다. 현재 최신 버전이며, 구글링해서 찾아봐도 원인을 모르겠네요 ㅠ 짐작이 가는거는 버전이 달라서인데 현재 제 크롬은 최선 버전으로 115.0.5790.102 입니다. 그래서 https://googlechromelabs.github.io/chrome-for-testing/ 이 사이트에서 win64로 받았는데 시도했는데 현재 안되는 상태입니다
-
미해결[리뉴얼] 파이썬입문과 크롤링기초 부트캠프 [파이썬, 웹, 데이터 이해 기본까지] (업데이트)
섹션 4에 마지막 강의 14분 20초에 질문드립니다.
먼저 저는 'div.alertbar' 내에 문자로 된 것이 제가 추출하고 싶은 것 밖에 없어 그냥 이렇게 해도 되겠다 싶어 바로 이렇게 추출했습니다.#내 코드import requestsfrom bs4 import BeautifulSoupres = requests.get('https://davelee-fun.github.io/index.html')soup = BeautifulSoup(res.content,'html.parser')mydata = soup.select_one('div.alertbar')print(mydata.get_text().strip()) 그리고 다른 것을 시도해 보다 든 생각인데 import requestsfrom bs4 import BeautifulSoupres = requests.get('https://davelee-fun.github.io/index.html')soup = BeautifulSoup(res.content,'html.parser')mydata = soup.find('span',attrs={'class':'alertbar','style':'display: block'})print(mydata.get_text().strip()) 코드 블럭에서 처럼 이런식으로 속성:속성값으로 문제를 해결해보려 했으나 style이라는 속성은 css언어로 프로퍼티와 그 값이 있어 불가능해 보였습니다.. 혹시 가능한 방법이 있을까요?
-
미해결[리뉴얼] 파이썬입문과 크롤링기초 부트캠프 [파이썬, 웹, 데이터 이해 기본까지] (업데이트)
섹션 4 마지막 강의 9분 30초
제가 짠 코드 인데 신박하게 짠 것 같아 기분이 좋아서 올렸습니다.import requestsfrom bs4 import BeautifulSoupres = requests.get('https://davelee-fun.github.io/index.html')soup = BeautifulSoup(res.content,'html.parser')mydata = soup.select('h4.card-text')i=0while i<4:print(mydata[i].get_text().strip())i+=1 분명 더 쉬운 방법이 있지만...# 내 코드2import requestsfrom bs4 import BeautifulSoupres = requests.get('https://davelee-fun.github.io/index.html')soup = BeautifulSoup(res.content,'html.parser')featured = soup.select('.featured-posts')for i in featured: y = i.select('h4.card-text') for x in y: print(x.get_text().strip()) 이렇게 두번째 코드는 강사님이랑 비슷하게 짜게 되었습니다.
-
미해결[리뉴얼] 파이썬입문과 크롤링기초 부트캠프 [파이썬, 웹, 데이터 이해 기본까지] (업데이트)
섹션 4 마지막 강의 5분 40초 질문드립니다.
# 내 코드import requestsfrom bs4 import BeautifulSoupres = requests.get('https://davelee-fun.github.io/index.html')soup = BeautifulSoup(res.content,'html.parser')mydata = soup.find_all('a','nav-link') for i in mydata:print(i.get_text()) 저는 코드를 이렇게 작성해봤는데요 결과적으로 Blog와 About이 잘 나왔습니다. (저는 find_all 함수 사용했습니다.)그런데 mydata = soup.find_all('a','nav-link') 이 문장에서 굵게 표시된 부분을 a.nav-link로 적으면 아무것도 출력이 안되는데 왜 안되는지 궁금합니다. 태그명.class명 이렇게 하는 방법은 css selector에서만 허용되는 걸까요?코드 그대로 select일 때는 가능합니다.
-
미해결[리뉴얼] 파이썬입문과 크롤링기초 부트캠프 [파이썬, 웹, 데이터 이해 기본까지] (업데이트)
섹션4 마지막에서 두번째 강의의 6분38초내용입니다.
단순히 이 코드에서 질문있습니다.select 와 find는 파싱직후 상태의 코드에서 제가 원하는 코드를 찾아주는 역할인데 처음 select('tr)에서 select가 사용되면서 items는 list형태가 되고 그 list형태인 items를 하나씩 뽑아내기 위해 for문을 사용했습니다.이때 items에서 for문을 돌려 뽑아진 item은 그 형태가 어떤지 모르겠으나 파싱 직후의 코드상태와 형태가 같기 때문에 select를 한번 더 사용할 수 있는 것 같은데 맞나요? 그리고 제가 생각한 flow는 tr tag를 기준으로 select를 해서 반환된 list가 items에 들어가고 그 items에서 for문에 들어간 처음 코드(list-->파싱 직후의 코드 형태)가 td tag를 기준으로 다시 select가 진행된다 판단했습니다. (두번째 select는 tr tag 안에 td tag가 아닌 다른 tag가 있을 수 있으므로 td tag만 뽑아내기 위해 해줬다 생각했습니다.)이 논리도 맞는지 궁금합니다.
-
미해결[리뉴얼] 파이썬입문과 크롤링기초 부트캠프 [파이썬, 웹, 데이터 이해 기본까지] (업데이트)
질문이 두가지 있습니다.
CSS selector를 사용하여 크롤링을 하는 방법 강의에서 질문 있습니다.강의는 섹션 4에 3강이구요. 12분 15초부터 진행되는데 지금 강사님이 올려주신 깃허브 코드가 좀 바껴서 그런지 모르겠는데 li.course.paid라는 코드 자체가 없어요. 그래서 제가 (중급) - 자동으로 쿠팡파트너스 API 로 가져온 상품 정보, 네이버 블로그/트위터에 홍보하기 [412] 이 문장을 css selector로는 도저히 크롤링을 못하겠어서 find를 사용해서 크롤링을 시도해봤으나 코드가 안되네요. 제가 작성한 코드입니다.(find 함수 사용)import requestsfrom bs4 import BeautifulSoupres = requests.get('https://davelee-fun.github.io/blog/crawl_test')soup = BeautifulSoup(res.content,'html.parser')items = soup.find_all('a') print(items) 먼저 코드를 이렇게 작성해 list형태로 나오는걸 확인 후 import requestsfrom bs4 import BeautifulSoupres = requests.get('https://davelee-fun.github.io/blog/crawl_test')soup = BeautifulSoup(res.content,'html.parser')items = soup.find_all('a') for title in items: print(title[15].get_text())이렇게 진행해보았는데 안됩니다... 질문1, 제가 작성한 코드에 잘못된 점 있을까요?질문2. 지금 올라와있는 깃허브코드에서<a href="(중급)">https://www.fun-coding.org">(중급) - 자동으로 쿠팡파트너스 API 로 가져온 상품 정보, 네이버 블로그/트위터에 홍보하기 [412]</a>도저히 css selector로 해당 문장만 뽑아내는 방법이 생각이 안납니다.이것도 import requestsfrom bs4 import BeautifulSoupres = requests.get('https://davelee-fun.github.io/blog/crawl_test')soup = BeautifulSoup(res.content,'html.parser')items = soup.select('ul#dev_course_list>li.course') for title in items: print(title[8].get_text())이렇게 해보니까 안되네요.