inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

네이버 쇼핑 크롤링 1

해결됨

실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용

강의 : 네이버 쇼핑 크롤링 1 , 11:14 시점에서 막힙니다. from bs4 import BeautifulSoup import requests keyword = input("검색할 제품을 입력하세요 : ") url = "https://search.shopping.naver.com/search/all?query={keyword}" user_agent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Mobile Safari/537.36" headers = {'User-Agent': user_agent} req = requests.get(url, headers=headers) html = req.text # print(html[:1000]) 확인용 soup = BeautifulSoup(html, "html.parser") base_divs = soup.select("[class^=product_item]") # product_item 로 클래스 이름이 시작되는 클래스 # print(base_divs) print(len(base_divs)) for base_div in base_divs: title = base_div.select_one("[class^=product_link]") print(title.text) 우선 강의에서는 basicLis_item, basicList_link 로 했는데 현재 네이버 쇼핑몰에서는 product_item***, product_link*** 로 되어 있습니다. 아래 스샷처럼요. 그런데 코드를 치니까 이상한게 나와요 자꾸.. 이유가 뭘까요 ??

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
jtk5648 댓글 1 좋아요 0 조회수 1339

higher order function 에서

미해결

실리콘밸리 엔지니어가 가르치는 파이썬 기초부터 고급까지

128줄에 return inside에서 inside()를 안하는 이유가 궁금합니다 @higher_order_example 자체가 inside 리턴받은 함수를 자동으로 ()붙여서 실행해주는 것인가요? 136줄에 sample_example()을 안쓰면 121줄에 있는 func 매개변수로 못넣는것인가요???

  • python
  • 알고리즘
남기정 댓글 2 좋아요 1 조회수 371

선생님 데이터 import가 안돼요 ㅠㅠ

미해결

[개정판] 파이썬 머신러닝 완벽 가이드

- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 강의 내용을 질문할 경우 몇분 몇초의 내용에 대한 것인지 반드시 기재 부탁드립니다. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 선생님 보스턴 가격예측 데이터 임포트가 안돼요 ㅠㅠ

  • python
  • 머신러닝
  • 통계
이호준 댓글 2 좋아요 0 조회수 498

'블랙핑크' 검색 시에만 오류가 뜨는 현상

미해결

[신규 개정판] 이것이 진짜 크롤링이다 - 실전편 (인공지능 수익화)

안녕하세요. 강사님 아래 코드에서 '블랙핑크' 를 검색할 때 Traceback (most recent call last): File "c:\pratice_crolling\심화1_\03_스포츠 뉴스 크롤링.py ", line 52, in <module> print(article_title.text.strip()) ^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'text' 다음과 같은 오류가 뜹니다 ㅠㅠ CSS 선택자, 오타도 모두 맞게 확인이 되는데 왜 저 검색어만 오류가 뜰까요ㅠㅠ? # -*- coding: euc-kr -*- # 네이버에서 손흥민, 오승환과 같은 스포츠 관련 검색어 크롤링하기 import requests from bs4 import BeautifulSoup import pyautogui import time search = pyautogui.prompt("어떤 것을 검색하시겠어요?") response = requests.get(f"https://search.naver.com/search.naver?sm=tab_hty.top&where=news&query={search}&oquery=%EC%98%B7%EC%9C%BC%ED%99%98&tqi=i74G%2FdprvTossZPeMhCssssssko-058644") html = response.text soup = BeautifulSoup(html, "html.parser") articles = soup.select(".info_group") for article in articles: # '네이버뉴스' 가 있는 기사만 추출한다. (<a> 하이퍼링크가 2개 이상인 경우에 해당) 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 "sports" in url: article_title = soup.select_one("h4.title") article_body = soup.select_one("#newsEndContents") # 본문 내에 불필요한 내용 제거 p태그와 div태그의 내용은 출력할 필요가 없다. 없애주자. p_tags = article_body.select("p") # 본문에서 p 태그인 것들을 추출 for p_tag in p_tags: p_tag.decompose() div_tags = article_body.select("div") # 본문에서 div 태그인 것들을 추출 for div_tag in div_tags: div_tag.decompose() # 연예 기사인 경우 elif "entertain" in url: article_title = soup.select_one(".end_tit") article_body = soup.select_one("#articeBody") # 일반 뉴스 기사인 경우 else: article_title = soup.select_one("#title_area") article_body = soup.select_one("#dic_area") # 출력문 print("==================================================== 주소 ===========================================================") print(url.strip()) print("==================================================== 제목 ===========================================================") print(article_title.text.strip()) print("==================================================== 본문 ===========================================================") print(article_body.text.strip()) #strip 함수는 앞 뒤의 공백을 제거한다. time.sleep(0.3)

  • python
  • 웹-크롤링
댓글 2 좋아요 0 조회수 325

똑같이 따라했는데 쿠팡 크롤링이 되질 않습니다 무엇이 문제일까요ㅜㅜ?

미해결

실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용

강의 내용 외 개인적인 실습 사이트의 질문은 답변이 제공되지 않습니다. 문제가 생긴 코드, 에러 import requests from bs4 import BeautifulSoup import time bass_url = "https://www.coupang.com/np/search?component=&q=" keyword = input("검색할 상품을 입력하세요 : ") search_url = bass_url + keyword headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36" } cookie = {"a": "b"} time.sleep(1) req = requests.get(search_url, timeout=5, headers=headers, cookies=cookie) #print(req.status_code) html = req.text soup = BeautifulSoup(html, "html.parser") items = soup.select("[class=search-product]") rank = 1 for item in items: badge_rocket = item.select_one(".badge.rocket") if not badge_rocket: continue name = item.select_one(".name") price = item.select_one(".price-value") thumb = item.select_one(".search-product-wrap-img") link = item.a["href"] print(f"{rank}위") print(name.text) print(f"{price.text} 원") print(f"https://www.coupang.com/{link}") if thumb.get("date-img-src"): img_url = f"http:{thumb.get('date-img-src')}" else: img_url = f"http:{thumb['src']}" print(img_url) print() # img_req = requests.get(img_url) # with open(f"C:\soncoding\coupang{rank}.jpg", "wb") as f: # f.write(img_req.content) rank += 1 타임까지 걸어보고 쿠키까지 한번 변경을 해봤는데 계속 뜨질 않습니다. 베이스는 강사님의 코드와 똑같이 적었습니다!

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
SETO 댓글 1 좋아요 0 조회수 1373

api 질문입니다.

해결됨

[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스

포토폴리오 마이페이지 - 내포인트 부분을 작업하는 도중 api 질문입니다. fetchPointTransactionsOfBuying 이 내포인트 -> 구매내역 api로 알고있습니다. 피그마를 보면 거기서 판매자 데이터를 가져오고있는데 오류가 뜨네요.ㅠ 판매자 데이터를 가져오고 싶은데 여기서 seller {name} 이부분을 넣으면 데이터가 안가져오네요.. 판매자데이터가 없어서 그런건지 왜 그런지와 어떻게 해야하는지 두가지 모두 알고싶습니다.

  • react
  • node.js
  • seo
  • graphql
  • next.js
임프런 댓글 2 좋아요 0 조회수 381

크롬드라이브 실행 오류

미해결

[신규 개정판] 이것이 진짜 엑셀자동화다 - 기본편

AttributeError: 'str' object has no attribute 'capabilities' 주요 에러는 이렇게 뜨는데.. 구글링을 해보긴 했는데 어떻게 해결을 해야될지 모르겠습니다ㅠ 혹시 도움을 구할 수 있을까요?

  • python
  • selenium
  • openpyxl
서영은 댓글 4 좋아요 1 조회수 15450

왜 전 service 인자를 받을 수 없다고 나올까요 ...?

미해결

실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용

[현재 화면 크기 지정하는 옵션 추가, 유저 에이전트 사용법] 강의에서 <03:38> 지점에 대한 질문입니다. 제가 아래와 같은 코드를 실행 후 오류 메시지가 떴습니다. from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from webdriver_manager.chrome import ChromeDriverManager user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.0.0 Safari/537.36" options = Options() options.add_experimental_option("detach", True) options.add_argument(f"user-agent={user_agent}") # options.add_experimental_option("--start-maximized") # options.add_experimental_option("--start-fullscreen") options.add_argument("window-size=500, 500") service = Service(ChromeDriverManager().install()) driver = webdriver.Chrome("../driver/chromedriver.exe", service = service, options=options) url = "https://naver.com" driver.get("url") time.sleep(2) AI 에게 질문을 해보니, 아래와 같은 해답을 내놓았는데, 어떻게 코드를 작성해야 할까요? 새로 업데이트 된 셀레니움에서도 service는 문제 없이 잘 돌아간다고 알고 있는데, 문제 발생 이유가 궁금합니다...

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
jtk5648 댓글 2 좋아요 0 조회수 389

셀레니움 option

해결됨

실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용

셀레니움 최신 버전에서 service를 쓸 수 없는데, 이제 다음과 같은 코드에서 option 기능은 어떻게 코드를 짜면 될까요? 아래 코드에서 service 부분을 빼야할까요? 셀레니움 버전 업그레이드와 함께 코드에서 수정할 부분이 있을까요? 위는 코드랑 출력 결과이고 아래는 코드만 따로 옮긴 것입니다. from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager import time user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" options = Options() options.add_experimantal_option("detach", True) options.add_argument(f"user-agent={user_agent}") # options.add_argument("--start-maximized") # options.add_argument("--start-fullscreen") options.add_argument("window-size=500, 500") # driver = webdriver.Chrome("../driver/chromedriver.exe") service = Service(ChromeDriverManager().install()) driver = webdriver.Chrome(service=service, options=options) url = "https://naver.com" driver.get(url)

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
jtk5648 댓글 2 좋아요 0 조회수 776

실행이 안 됩니다

미해결

웹 자동화 프로그램 만들기(파이썬 + 셀레니움)

셀레니움과 크롬 실치를 했는데 실행하려고 하니 오류 페이지가 뜹니다 C:\Users\USER\miniconda3\python.exe C:\Users\USER\PycharmProjects\pythonProject1\video.py Traceback (most recent call last): File "C:\Users\USER\PycharmProjects\pythonProject1\video.py", line 3, in <module> driver = webdriver.Chrome("./chromedriver") File "C:\Users\USER\miniconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__ self.service.start() File "C:\Users\USER\miniconda3\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start self.process = subprocess.Popen(cmd, env=self.env, File "C:\Users\USER\miniconda3\lib\subprocess.py", line 971, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\USER\miniconda3\lib\subprocess.py", line 1456, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, OSError: [WinError 193] %1은(는) 올바른 Win32 응용 프로그램이 아닙니다 종료 코드 1(으)로 완료된 프로세스

  • python
  • selenium
남은 댓글 3 좋아요 0 조회수 1573

src 잘못된 링크 검색 여부

미해결

실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용

src에서는 잘못된 썸네일 링크들이 간혹 있잖아요, 예를 들어 "// img1a.coupangcdn.com/image/coupang/search/blank1x1.gif " 이런 링크들이요 그런데 아래 이미지 처럼 왜 꼭 "페이지 소스 보기"에서 검색을 해야 링크가 어디 있는지 찾을 수 있고 왜 그냥 페이지에서 개발자 도구를 검색을 하면 이 잘못된 링크들은 검색이 되지를 않는거죠? 이렇게 여기서 검색을 하면 하나도 나오지 않습니다. 혹시 오류가 있는건지 원래 안뜨는건지.. 알 수 있을까요 ?(다른 올바른 썸네일 링크는 또 여기서 검색하면 뜨더라고요)

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
jtk5648 댓글 1 좋아요 0 조회수 601

(쿠팡)썸네일 링크가 출력이 안되네요

해결됨

실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용

이렇게 코드 작성을 했는데, 강의와는 다르게 출력이 안되네요 현재 강의는 쿠팡 크롤링의 [상품 링크, 썸네일 url 가져오기] 이고, 시점은 04:14 입니다. 강의 영상 내 html하고 지금 쿠팡 html 하고 비교도 해봤는데 틀린 것이 없고 오타도 없는 것 같은데 문제가 뭘까요 ? import requests from bs4 import BeautifulSoup headers = { "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36", "accept-language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7" } cookie = {"a" : "b"} base_url = "https://www.coupang.com/np/search?component=&q=" keyword = input("검색어 입력하세요 : ") search_url = base_url + keyword req = requests.get(search_url, timeout=5, headers=headers, cookies=cookie) html = req.text soup = BeautifulSoup(html, "html.parser") items = soup.select("[class=search-product]") print(len(items)) rank = 1 for item in items: badge_rocket = item.select_one(".badge.rocket") if not badge_rocket: continue name = item.select_one(".name") price = item.select_one(".price-value") thumb = item.select_one("search-product-wrap-img") link = item.select_one("a")["href"] # or item.a["href"] print(f"{rank}위") print(name.text) print(f"{price.text} 원") # print(link) print(thumb["src"]) print() rank += 1 결과는 이렇게 뜨네요 쿠팡 html 입니다.

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
jtk5648 댓글 1 좋아요 1 조회수 681

PDF파일이 어디에 있나요?

해결됨

Python 알고리즘 베스트 10

안녕하세요 PDF파일은 출력하려고 하는데, 노션을 보면 "PDF 노션 페이지에서 다운로드하실 수 있습니다." 로만 되어있는데 다운받을 수 있는 링크는 어디에 있나요? 노션에서 전체PDF출력하려면 비지니스라서 불가능한데... 확인부탁드립니다.

  • python
  • 코딩-테스트
한형섭 댓글 2 좋아요 0 조회수 485

오류가 계속 뜨네요

해결됨

실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용

현재 네이버 view 탭 검색 결과 크롤링 3 , 10분 43초 지점입니다. 손흥민, 파이썬, 블랙핑크 검색해보고 개발자 탭에서 .api_ani_send 까지 각각 다 확인해서 강의 대로 타이핑 해서 쳤더니 전 0 이라고 나옵니다. 눈으로 직접 확인까지 하고 해보는데도 왜 에러가 나는 건가요 ? import requests from bs4 import BeautifulSoup keyword = input("검색어를 입력하세요. : ") base_url = "https://search.naver.com/search.naver?where=view&sm=tab_jum&query=" headers = {"User-Agent" : "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36"} url = base_url + keyword req = requests.get(url, headers=headers) html = req.text soup = BeautifulSoup(html, "html.parser") items = soup.select(".api_ani_send") for rank_num, area in enumerate(items, 1): print(f"<<<{rank_num}>>>") ad = area.select_one(".link_ad") if ad: print("광고입니다.") continue title = area.select_one(".api_txt_lines.total_tit") # 빈 칸을 . 으로 맞춰줘야한다. name = area.select_one(".sub_txt.sub_name") print(name.text) print(title.text) print(title['href']) print() print(len(items))

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
jtk5648 댓글 1 좋아요 1 조회수 341

admin 에 나타나지 않는 몇몇 필드들

미해결

파이썬/장고 웹서비스 개발 완벽 가이드 with 리액트

안녕하세요, 강의를 잘 듣고 있습니다. 모델 필드에 있는 몇몇 필드들이 admin에 나타나지 않더군요 예를 들면, updated_at, created_at 같은 필드들이요 이를 위해서 admin 페이지에 일일히 모델 필드를 list_display에 등록해줘야 하는게 맞나요? from django.contrib import admin # Register your models here. from .models import * admin.site .empty_value_display = "-empty-" admin.site .register(Product) admin.site .register(CartProduct) class OrderAdmin(admin.ModelAdmin): list_display = ['customer', 'transaction_id', 'total_price'] admin.site .register(Category) admin.site .register(UserProfile) admin.site .register(Order) admin.site .register(OrderedProduct) admin.site .register(ShipmentInfo) 그럼 제가 직접만든 모델의 경우에는 그렇다 쳐도.. allauth에 있는 site domain 부분이 나오질 않는거에요 ㅠㅠ... 제가 뭘 잘못 건드렸는 지 모르겠는데, 맨처음 프로젝트할 때에는 allauth의 소셜 어플리케이션 부분에 사이트 도메인을 입력할 수 있는 커다란 박스가 있었는데, 그것만 또 안난옵니다. 제가 뭘 잘못한건지 ㅠㅠ 원래 잘 나오던건데... 이번에 파이참 커뮤니티 에디션에서 유료버전으로 바꾸고, 프로젝트를 만들고 나니 admin에 몇몇 모델의 필드들이 잘 보이지 않습니다. verbose name을 설정된것들이 특히 그런 거 같은데 무엇이 문제인지 도통 모르겠습니다. 그렇다고 allauth를 제가 admin에 등록해야하는걸까요? 2.제가 모르는 무언가가 있는걸까요?

  • react
  • python
  • django
  • docker
paichai17 댓글 1 좋아요 0 조회수 307

왜 계속 실행은 되는데 출력이 안될까요 ???

해결됨

실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용

현재 강의는 "네이버 view탭 검색결과 크롤링 2" 이며 00:46 지점입니다. 계속 ".total_area"를 선택하고 for 문도 강의에서랑 똑같이 작성해서 실행하는데 출력이 안나옵니다. 어디를 고쳐야할까요 ?

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
jtk5648 댓글 1 좋아요 1 조회수 393

ansible-server에 pywinrm 설치 시, 에러 발생하여 문의드립니다.

미해결

구성 관리 자동화 도구 - 앤서블(Ansible)

안녕하세요. 아래 섹션 실습 중, 에러가 발생하여 문의드립니다. 섹션 9 : [응용] 윈도우 관리학 - (1)베이그런트를 이용해서 윈도우를 추가하기 Ansible_env_ready.yaml 에 아래와 같이 추가 후, vagrant provision ansible-server을 수행했는데 pvwinrm 설치 과정에서 에러가 발생하였습니다. - name: Install python-pip yum: name: python-pip state: present - name: Install pywinrm pip: name: pywinrm state: present ansible-server에 접속하여 수동으로 pip install pywinrm을 수행했는데 역시 에러가 발생합니다. python 버전을 업그레이드 하라고 메시지가 나오는데 향후 수업 따라하기 시, 영향이 있을 듯 하여 선뜻 테스트하지 못 하고 있습니다. 해결 방법에 대해서 가이드 부탁드리겠습니다. 감사합니다 !

  • ansible
  • pywinrm
  • python
doore.park 댓글 1 좋아요 0 조회수 638

셀레니움으로 크롬 실행 후 자동으로 창이 닫힙니다.

미해결

실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용

from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebkit/537.36 (KHTML, like Gecko) Chrome/70.0.0.0 Safari/537.36" options = Options() options.add_experimental_option("detach", True) options.add_argument(f"user-agent={user_agent}") # options.add_argument("--start-maximized") # options.add_argument("--start-fullscreen") # options.add_argument("window-size=500,500") # options.add_argument("--headless") # options.add_argument("--disable-gpu") options.add_argument("--mute-audio") options.add_argument("incognito") service = Service(ChromeDriverManager().install()) driver = webdriver.Chrome(service=service, options=options) url = "https://naver.com" driver.get(url) print(driver.page_source[:1000]) # driver.quit() 수업 진행을 그대로 따라 하였습니다. 다만 코드 실행은 잘 되지만 크롬창이 계속해서 종료가 되어 그것을 막는 코드를 입력해도 계속 자동 종료가 됩니다 저의 크롬 버전은 버전 114.0.5735.199(공식 빌드) (64비트) 이며 셀레니움 버전은 4.10.0 입니다! 진도를 따라 가고싶으나 계속해서 창이 꺼져 진행이 어렵습니다 ㅠㅠ 도움을 원합니다.

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
SETO 댓글 1 좋아요 0 조회수 1420

Web 태그 접속후, 최근 사진 없습니다.?

미해결

[자동화 완전 정복] 인스타그램 휴대폰, 웹 자동화 프로그램 개발

Web 태그 접속후, 최근 사진 영역이 없습니다.

  • python
  • selenium
lin1005 댓글 2 좋아요 0 조회수 415

인기 태그

인프런 TOP Writers

주간 인기글