월 15,400원
5개월 할부 시다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결이것이 진짜 크롤링이다 - 실전편
여러 페이지 가져오기
강사님,여러 페이지 가져오기를 위해 request url를 확인하는데https://my.pitchbook.com/static/web/4bb938fc29465a9b091506661e90ac7c.woff처럼 각 페이지로 이동해도 url이 변하지 않습니다.강사님께서는 네이버에서 적용하기 버튼을 눌러서 url을 복사했는데, 적용하기 버튼이 없어도 url이 바뀌나요?이와 같은 경우에는 강의에서 알려주신 방법을 사용하지 못하는건가요? 감사합니다.
- 미해결이것이 진짜 크롤링이다 - 실전편
서버 배포시 문의드려요..
안녕하세요.장고로해서 우분투 서버에 배포중인데요. 셀레니움 이용시크롬과 크롬 웹 드라이버가 서버 컴퓨터에 깔려있어야하는 걸까요,클라이언트 컴퓨터에 깔려있어야 하는걸까요? 아래와 같이 옵션 뭘 설정하라는데.. chrome_options.binary_location = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" chrome_driver_binary = "/usr/local/bin/chromedriver" 혹시 아시면 답변 부탁드려요.
- 미해결이것이 진짜 크롤링이다 - 실전편
syntax 에러
강사님, 셀리니움 기본 설정 따라하는데 syntax error가 뜹니다.이번 뿐만 아니라 다른 어떤 코드를 적용해보아도 디폴트로 syntax에러가 뜨는데 이유가 무엇인가요?
- 미해결이것이 진짜 크롤링이다 - 실전편
난독화(?) 크롤링
안녕하세요.클래스나 ID가 난독화(?)된 형태의 경우이거는 해당 사이트 빌드할때마다 변경된다던데요.이런 경우 구조적으로 크롤링 할수밖에 없는걸까요? *1ialerq 같은 경우
- 미해결이것이 진짜 크롤링이다 - 실전편
requests, soup로 크롤링 했을때 안가져와지는 경우 어떻게 해야하나요?
안녕하세요.문의드려요. 실전으로 쇼핑몰들 크롤링 해보고 있는데요.상품 상세 페이지라면 가격, 브랜드명 이런건 되는데,상품 상세 정보 부분은 크롤링이 안되더라고요. 지그재그 등header에 에이전트 모질라 넣어도 안되고.. 그리고 어떤 사이트는 res.statusCode 찍어보면 403이나 404가 오는 사이트도 있고.. 위 두가지 유형처럼 막혀있을 경우 뚫을 수 있는 방법이 있을까요?
- 미해결이것이 진짜 크롤링이다 - 실전편
네이버 로그인
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By # 크롬 드라이버 자동 업데이트 from webdriver_manager.chrome import ChromeDriverManager import time import pyautogui import pyperclip # 브라우저 꺼짐 방지 chrome_options = Options() chrome_options.add_experimental_option("detach", True) #불필요한 에러 메시지 없애기 chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"]) service = Service(executable_path=ChromeDriverManager().install()) driver = webdriver.Chrome(service=service, options=chrome_options) # 웹페이지 해당 주소 이동 driver.implicitly_wait(5) driver.maximize_window() driver.get("https://nid.naver.com/nidlogin.login") # 아이디 입력창 id = driver.find_element(By.CSS_SELECTOR, "#id") id.click() pyperclip.copy("******") pyautogui.hotkey("command", "v") time.sleep(2) # 비밀번호 입력창 pw = driver.find_element(By.CSS_SELECTOR, "#pw") pw.click() pyperclip.copy("********") pyautogui.hotkey("command", "v") time.sleep(2) # 로그인 버튼 login_btn = driver.find_element(By.CSS_SELECTOR, "#log\.login") login_btn.click() 로그인과 비밀번호 실행할 때마다 v로 아님 없음으로 또는 비밀번호만 눌러지고 하네요 정확도가 많이 떨어집니다.
- 미해결이것이 진짜 크롤링이다 - 실전편
첫번째 페이지 크롤링하기 _ 실행안됨
2022.04.28 에 업데이트 해주신 코드를 그대로 긁어서 실행해도아래와 같이 터미널에 실행내역(?)만 뜨고 별도 아무 반응이 없는 것 같은데 해결방법 알려주시면 감사하겠습니다..! C:\startcoding> c: && cd c:\startcoding && cmd /C "C:\Users\yjeon019\AppData\Local\Programs\Python\Python310\python.exe c:\Users\yjeon019\.vscode\extensions\ms-python.python-2023.10.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher 65533 -- "c:\startcoding\Chapter08_쿠팡\01. 첫번째페이지크롤링.py" "
- 미해결이것이 진짜 크롤링이다 - 실전편
첫번째 페이지 크롤링하기
2022.04.28 에 업데이트 해주신 코드를 그대로 긁어서 실행해도아래와 같이 터미널에 실행내역(?)만 뜨고 별도 아무 반응이 없는 것 같은데 해결방법 알려주시면 감사하겠습니다..! C:\startcoding> c: && cd c:\startcoding && cmd /C "C:\Users\yjeon019\AppData\Local\Programs\Python\Python310\python.exe c:\Users\yjeon019\.vscode\extensions\ms-python.python-2023.10.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher 65533 -- "c:\startcoding\Chapter08_쿠팡\01. 첫번째페이지크롤링.py" "
- 해결됨이것이 진짜 크롤링이다 - 실전편
심화 학습
안녕하세요.강의 잘 들었습니다.대부분의 사이트는 셀레니움과 bs4, requests 를 조합하면 정보를 가져올 수 있지만, 문제는 동적 사이트의 경우 시간이 걸린다는 점 입니다.예를 들어, 네이버 지도를 대상으로 필요한 데이터를 가져올 때, 저의 경우는 100개의 가게 정보를 모두 가져오는데 5~6분 정도가 소요되는 반면, 크롤링을 전문적으로 하시는 분들은 더 빠르게 작업을 완료하시는 것 같더라구요.자세히는 모르겠지만 패킷 등등의 기술을 활용하시는 것 같은데, 이런 내용을 학습할 수 있는 방법이 있을까요?크롤링을 활용해서 부업을 하려고 했는데, 막상 전문적으로 하시는 분들을 보니, 상대가 될 것 같지 않은 답답한 마음에 질문 드렸습니다.
- 미해결이것이 진짜 크롤링이다 - 실전편
쿠팡 페이지 지정 출력
안녕하세요 쿠팡 크롤링 100개 상품 출력 강의를 듣고 코드를 작성했는데요, 똑같이 작성을 해봐도 페이지만 숫자만 출력되고 안에 내용이 출력되지 않습니다 ㅠ 코드 한번만 확인 부탁드려도 될까요? import requests from bs4 import BeautifulSoup import pyautogui keyword = pyautogui.prompt("검색어를 입력하세요 >> ") rank = 1 done = False for page in range(1,5): if done == True: break print(page, "번째 페이지 입니다.") main_url = "https://www.coupang.com/np/search?&q={keyword}&page={page}" coupang_header = { 'Host': 'www.coupang.com', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Language': 'ko-KR,ko;q=0.8,en-US;q=0.5,en;q=0.3', } response = requests.get(main_url, headers=coupang_header) html = response.text soup = BeautifulSoup(html, "html.parser") links = soup.select("a.search-product-link") for link in links: if len(link.select("span.ad-badge-text")) > 0: print("광고상품 입니다.") else: sub_url = "https://www.coupang.com/" + link.attrs['href'] response = requests.get(sub_url, headers=coupang_header) html = response.text soup = BeautifulSoup(html, "html.parser") try: brand_name = soup.select_one("a.prod-brand-name").text except: brand_name = "" product_name = soup.select_one("h2.prod-buy-header__title").text try: product_price = soup.select_one("span.total-price > strong").text except: product_price ="" print(rank, brand_name, product_name, product_price) rank = rank + 1 if rank > 100: done = True break
- 미해결이것이 진짜 크롤링이다 - 실전편
드롭다운 질문
안녕하세요! 정말 유용히 강좌 활용하고 있습니다. 타사이트 크롤링 시도 중 에러를 만나 질문드립니다.제가 이번에 크롤링을 시도하고 있는 사이트는 Amazon Australia (https://www.amazon.com.au/)입니다. 다만, 한국에서 호주 아마존 제품을 크롤링을 시도하고 있는 관계로 제 위치(또는 주소)를 호주 쪽으로 먼저 설정해야 아이템 리스트를 제대로 볼수가 있더라구요.그래서 해당 설정을 위해 아래와 같이 코드를 작성했습니다. 그런데 50번째 줄부터 에러가 생기네요.여기에 'Select your City'를 클릭하도록 한 후, 'Sydney'를 선택하도록 만들고 싶습니다. 혹시 제 코드가 왜 에러가 발생하는 지 혹은 개선할 점이나 의견 있으실까요? :)
- 미해결이것이 진짜 크롤링이다 - 실전편
네이버지도크롤링부분
안녕하세요 네이버지도 크롤링 부분을 듣다가 응용을 좀 해보고싶어서 그러는데 각 리뷰수,블로그리뷰수,등등 뽑아오는것은 가능하지만 각 상점마다 클릭을하여 리뷰를 작성한텍스트 부분도 같이 뽑아오고싶습니다(각 상점의 리뷰텍스트) 어떤 방식으로 진행을 해야할지 모르겠는데 조언 부탁드립니다.
- 미해결이것이 진짜 크롤링이다 - 실전편
header 관련 질문
안녕하세요. 현재 거의 완강을 한 학생이자, 업무에서도 크롤링을 나름 잘 활용하고 있습니다. 그래도 여러 가지 어려운 에러를 많이 만나는데, 그 중 하나가 header 관련 입니다. 우선, 제가 크롤링을 시도하고 있는 웹사이트는 라쿠텐 일본 (https://search.rakuten.co.jp/search/mall/-/560202/?p=2&used=1) 웹사이트입니다. 1페이지까지는 크롤링이 잘 되는데, 2페이지부터는 크롤링이 되지 않고, 하기와 같은 화면이 나오네요.제가 구글링을 많이 해본 결과, 웹사이트에서 크롤링 방지를 위해 무엇인가 설정을 해놓은 것이 아닐까 생각이 되고, 그래서 수업 중에 설정했던 header에 관해 여러 설정을 해보고 있는데, 아직 성공적으로 돌리지 못했네요. 전 셀레니움을 사용해서 다음과 같은 설정을 추가해봤습니다만, 혹시 관련해서 조언을 주실만한 사항이 있을까요?헤더나 설정을 할 때 무엇이 어떻게 필요한지 어떻게 아는지도 매우 궁금합니다.
- 해결됨이것이 진짜 크롤링이다 - 실전편
headless 내용이 포함되어 있나요?
강의 초반 진행중인데 셀레니움 headless 에 관한 내용도 나오나요?
- 미해결이것이 진짜 크롤링이다 - 실전편
팝업 창
안녕하세요.질문 있어 문의드립니다.브라우져 처음 접근할 때, 위 그림처럼 쿠키 동의 창이 계속 나오는데 어떻게 해야하나요?... 크롬으로 제가 접속할 때는 제가 예전에 이미 동의를 해놓아서 따로 뜨지 않는데, webdriver 통해서 들어가면 항상 이 창이 뜹니다.
- 미해결이것이 진짜 크롤링이다 - 실전편
id 값이 바뀐것같아서 찾아서 넣어보는데 잘안됩니다.
https://n.news.naver.com/mnews/article/003/0011827028?sid=101이곳에서 개발자모드에서 id값을 찾아서 해보고있는데계속 None만 반환되네요.이유를 모르겠습니다. 도와주세요
- 해결됨이것이 진짜 크롤링이다 - 실전편
03. 연예뉴스크롤링하기에 질문 있습니다.
import requests from bs4 import BeautifulSoup import time response = requests.get( "https://search.naver.com/search.naver?where=news&sm=tab_jum&query=%EB%B8%94%EB%9E%99%ED%95%91%ED%81%AC") html = response.text soup = BeautifulSoup(html, 'html.parser') articles = soup.select("div.info_group") # 뉴스 기사 div 10개 추출 for article in articles: links = article.select("a.info") # 리스트 if len(links) >= 2: # 링크가 2개 이상이면 url = links[1].attrs['href'] # 두번째 링크의 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("#articleBody") else: title = soup.select_one(".media_end_head_headline") content = soup.select_one("#dic_area") print("====링크====", url) print("====제목====", title.text.strip()) print("====본문====", content.text.strip()) time.sleep(0.3) 위와 같이 코드를 짜고 실행했는데,https://entertain.naver.com/read?oid=629&aid=0000209267이사이트 차례가 되자 content를 못 뽑아냅니다.다음과 같은 에러를 나타냅니다.====링크==== https://n.news.naver.com/mnews/article/629/0000209267?sid=106 ====제목==== 블랙핑크 지수, 요란하지 않은 '꽃'의 유혹[TF초점] Traceback (most recent call last): File "C:\Users\asd20\Desktop\startcoding_crawling\Chapter04\03.연예뉴스크롤링하기.py", line 27, in <module> print("====본문====", content.text.strip()) AttributeError: 'NoneType' object has no attribute 'text' 개발자도구를 눌러 html 구조를 확인해봐도 원인을 잘 모르겠습니다.
- 해결됨이것이 진짜 크롤링이다 - 실전편
네이버 일반 뉴스 페이지의 HTML이 변경된것 같습니다.
import requests from bs4 import BeautifulSoup response = requests.get( "https://search.naver.com/search.naver?where=news&sm=tab_jum&query=%EC%82%BC%EC%84%B1%EC%A0%84%EC%9E%90") html = response.text soup = BeautifulSoup(html, 'html.parser') articles = soup.select("div.info_group") # 뉴스 기사 div 10개 추출 for article in articles: links = article.select("a.info") # 리스트 if len(links) >= 2: # 링크가 2개 이상이면 url = links[1].attrs['href'] # 두번째 링크의 href를 추출 response = requests.get(url, headers={'User-agent':'Mozila/5.0'}) html = response.text soup = BeautifulSoup(html, 'html.parser') content = soup.select_one("#articleBodyContents") print(content.text)본문 내용의 ID가 articleBodyContents아닙니다.그래서 "#dic_area"로 생각해서,변경하고 진행했는데, 강사님처럼 전체 텍스트가 출력되는게 아니라 일부만 출력됩니다.전체 텍스트를 볼려면 어떻게 해야하나요?
- 미해결이것이 진짜 크롤링이다 - 실전편
for문에서 창 전환 후 에러 해결 방법 문의
from selenium import webdriver # webdriver 불러오기 from selenium.webdriver.chrome.options import Options # 브라우저 닫힘 방지 from selenium.webdriver.chrome.service import Service # 크롬드라이버 다운로드(새로운 버전 다시 받을 필요 없음) from webdriver_manager.chrome import ChromeDriverManager # 크롬드라이버 다운로드(새로운 버전 다시 받을 필요 없음) import time import pyautogui from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys options = Options() options.add_experimental_option('detach', True) # 브라우저 바로 닫힘 방지 options.add_experimental_option('excludeSwitches', ['enable-logging']) # 불필요한 메시지 제거 service = Service(ChromeDriverManager().install()) #service = Service(ChromeDriverManager().install()) 이 부분을 # ChromeDriverManager(path="원하는 경로") 이렇게 사용하면 원하는 곳에 # 크롬드라이버를 다운로드하게 됩니다. driver = webdriver.Chrome(service=service, options=options) driver.get("https://www.g2b.go.kr:8101/ep/tbid/tbidFwd.do") time.sleep(2) search_click = driver.find_element("#bidNm").click() keyword = pyautogui.prompt("<<<검색어를 입력하세요 >>>") search_keyword = driver.find_element(By.CSS_SELECTOR,"#bidNm").send_keys(keyword) output_num = driver.find_element(By.CSS_SELECTOR,"#recordCountPerPage").click() output_num_select = driver.find_element(By.CSS_SELECTOR,"#recordCountPerPage > option:nth-child(5)").click() search_btm_click = driver.find_element(By.CSS_SELECTOR,"#buttonwrap > div > a:nth-child(1)").click() bid_infors = driver.find_elements(By.CSS_SELECTOR,"tbody tr") for bid in bid_infors : title = bid.find_element(By.CSS_SELECTOR,"td:nth-child(4) > div > a").text link = bid.find_element(By.CSS_SELECTOR,"td:nth-child(4) > div > a").get_attribute('href') client = bid.find_element(By.CSS_SELECTOR,"td:nth-child(5) > div").text print("공고명 : ", title) print("주소 : ", link) print("발주처 : ",client ) print() # 사전규격 크롤링 driver.get("https://www.g2b.go.kr:8081/ep/preparation/prestd/preStdSrch.do") time.sleep(2) keyword2 = pyautogui.prompt("<<<검색어를 입력하세요 >>>") search_keyword2 = driver.find_element(By.CSS_SELECTOR,"#prodNm").send_keys(keyword2) output_num2 = driver.find_element(By.CSS_SELECTOR,"#recordCountPerPage").click() output_num2_select2 = driver.find_element(By.CSS_SELECTOR,"#recordCountPerPage > option:nth-child(5)").click() search_btm_click2 = driver.find_element(By.CSS_SELECTOR,"#frmSearch1 > div.button_wrap > div > a:nth-child(1)").click() bid_infors2 = driver.find_elements(By.CSS_SELECTOR,"tbody tr") for bid2 in bid_infors2: title2 = bid2.find_element(By.CSS_SELECTOR, "td:nth-child(4) > div > a").text client2 = bid2.find_element(By.CSS_SELECTOR, "td:nth-child(5) > div").text link_click = bid2.find_element(By.CSS_SELECTOR, "td:nth-child(4) > div > a").click() time.sleep(2) link2 = driver.current_url print("공고명 : ", title2) print("주소 : ", link2) print("발주처 : ",client2) print() driver.back() time.sleep(2) 위 코드에서 발생하는 코드는 아래와 같습니다. Traceback (most recent call last): File "c:\coding\나라장터크롤링\1.입찰공고크롤링.py", line 61, in <module> title2 = bid2.find_element(By.CSS_SELECTOR, "td:nth-child(4) > div > a").text File "C:\Users\landj\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webelement.py", line 425, in find_element return self._execute(Command.FIND_CHILD_ELEMENT, {"using": by, "value": value})["value"] File "C:\Users\landj\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webelement.py", line 403, in _execute return self._parent.execute(command, params) File "C:\Users\landj\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute self.error_handler.check_response(response) File "C:\Users\landj\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document이것 저것 다해봐도 안되네요...해결 방법을 알려주시면 감사하겠습니다.
- 해결됨이것이 진짜 크롤링이다 - 실전편
자바스크립트로 된 링크 가져오는 방법이 궁금합니다.
토요코인 수업 중에 위에 보는 것과 같이 자바스크립트로 링크가 걸려있는 경우 실제 url을 크롤링 하려면 어떻게 해야 하나요?