inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

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

선생님 쓱닷컴이 바뀌었는데 이런형태는 처음이라서 문의 드립니다.

미해결

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

쓱닷컴 이벤트 주소는 아래와같습니다. https://shinsegaemall.ssg.com/event/eventMain.ssg?Sgnb=event 문제는 이벤트 페이지가 1, 2 이렇게 2개 존재합니다. 문제는 1 페이지를 클릭하던 2페이지를 클릭하던, 주소가 모두 같습니다. 1페이지 클릭시 -> https://shinsegaemall.ssg.com/event/eventMain.ssg?Sgnb=event 2페이지 클릭시-> https://shinsegaemall.ssg.com/event/eventMain.ssg?Sgnb=event 이럴때는 어떻게 해야하나요? 셀레니움이 답일까요?

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
가후 댓글 1 좋아요 0 조회수 317

완강이 된건가요?

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

안녕하세요, 강사님 지금 강의실에 보면 섹션8에 작업형3, 가설검정 콘텐츠 제작중입니다 라고 뜨고 섹션 10.에 5회 기출유형(작업형1) 강의가 업로드 되지 않았습니다. 계속 강의가 업데이트 중 인가요? 감사합니다.

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
댓글 1 좋아요 0 조회수 318

로비 채팅 구현 섹션에서

해결됨

파이썬/장고로 웹채팅 서비스 만들기 (Feat. Channels) - 기본편

안녕하세요 로비 채팅 구현 강의를 들으면서 구현 중인데 redis 서버도 정상적으로 잘 작동하고 스크립트도 정확하게 썼는데 계속 채팅을 입력하고 엔터를 누르면 새로고침(초기화)이 되네요 ㅠㅠ 어떤게 문제일까요? 아무리 문제를 해결해봐도 이상한점은 찾아볼수가 없네요

  • python
  • django
  • django-channels
오창인 댓글 1 좋아요 0 조회수 306

계속 안됩니다..

미해결

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

actions.key_down(Keys.CONTROL).send_keys('v').key_up(Keys.CONTROL).perform() # id_input.send_keys(data.id) time.sleep(5) pw_selector = "#loginForm > div > div:nth-child(2) > div > label > input" pw_input = driver.find_element(By.CSS_SELECTOR,pw_selector) pw_input.click() time.sleep(5) actions = ActionChains(driver) # ctrl + c 동작 pyperclip.copy(data.pw) # ctrl + v 동작 actions.key_down(Keys.CONTROL).send_keys('v').key_up(Keys.CONTROL).perform()

  • python
  • selenium
김기솔 댓글 2 좋아요 1 조회수 342

오프라인 pip설치문의

미해결

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

좋은강의 감사드립니다. 덕분에 파이참설치했다가 Vscode로 갈아탔습니다. 다만 인터넷이 안되는 회사PC에서 업무자동화를 구현하려고 다양한 방법으로 pip install pyautogui를 설치하려고 해보았는데요 pip install pyautogui 를 실행하면 아래(이미지1)같이 뜨구요(아마 인터넷안되서 그런거아닌가 싶습니다만) 이미지1) 그래서 인터넷되는 피씨에서 pip install pyautogui 실행후 whl를 다운받아서 복사를 해놔도 import pyautogui가 실행이 되지는 않았구요 아래(이미지2)처럼 압축파일을 실행해도 작동하지는 않습니다. 이미지2 아래(이미지3)처럼 pip install 압축파일 을 실행해도 안되었습니다. 이미지2) 인터넷이 안되는곳에서 설치를 불가능한 것일까요?

  • python
  • selenium
  • openpyxl
intenet1 댓글 2 좋아요 0 조회수 1280

SendGird가입

미해결

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

안녕하세요 api 인증키를 발급받기 위해 sendgrid를 가입하려고 하는데 가입이 되지 않아서 질문남깁니다!!

  • react
  • python
  • django
  • docker
chlendyd7 댓글 3 좋아요 1 조회수 1125

requirements.txt 질문

해결됨

실전 프로젝트로 배우는 데이터 앱 만들기 with Python & Streamlit

안녕하세요 강의자료에는 requirements.txt가 안보이는 것 같은데 혹시 어디서 다운받을 수 있을까요? 버전 충돌이 발생해서요ㅠ

  • python
  • streamlit
이시현 댓글 1 좋아요 0 조회수 475

User Agent Data 변경하는 법 강의에서 아래처럼 계속 오류가 생깁니다..

미해결

파이썬 셀레니움 고급편 (python selenium - 크롤링, 크롤러)

User Agent Data 변경하는 법 강의에서 아래처럼 계속 오류가 생깁니다.. 코드는 동일하게 입력한 것 같은데.. 왜 그런 걸까요..? selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: Invalid parameters (Session info: chrome=114.0.5735.110) import requests from user_agents import parse from selenium import webdriver from selenium.webdriver.chrome.options import Options import chromedriver_autoinstaller import random, time, os chromedriver_autoinstaller.install() def make_user_agent(ua, is_mobile): user_agent = parse(ua) model = user_agent.device.model platform = user_agent.os.family platform_version = user_agent.os.version_string + ".0.0" # 모바일 기준이다 version = user_agent.browser.version[0] print('version: ', version) ua_full_version = user_agent.browser.version_string print('ua_full_version: ', ua_full_version) architecture = "x86" print(platform, ' platform') if is_mobile: platform_info = "Linux armv8l" else: # Window platform_info = "Win32" RET_USER_AGENT = { "appVersion" : ua.replace("Mozilla/", ""), "userAgent" : ua, "platform" : f"{platform_info}", "acceptLanguage": "ko-KR, kr, en-US, en", "userAgentMetadata": { "brands" : [ {'brand': 'Not.A/Brand', 'version': '8'}, {'brand': 'Chromium', 'version': '114'}, {'brand': 'Google Chrome', 'version':'114'} ], "fullVersion": f"{ua_full_version}", "platform" : platform, "platformVersion": platform_version, "architecture" : architecture, "model": model, "mobile": is_mobile } } return RET_USER_AGENT pc_device = ["1920,1440","1920,1200","1920,1080","1600,1200","1600,900", "1536,864", "1440,1080","1440,900","1360,768" ] mo_device = [ "360,640", "360,740", "375,667", "375,812", "412,732", "412,846", "412,869", "412,892", "412,915" ] width, height = random.choice(pc_device).split(",") UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" options = Options() UA_Data = make_user_agent(UA, True) # 랜덤 쿠키 생성하기 # ** 1~100의 숫자 이름의 폴더 밑에 쿠키를 생성해서 저장한다 rand_user_folder = random.randrange(1, 100) userCookieDir = os.path.abspath(f"./cookies/{rand_user_folder }") if os.path.exists(userCookieDir) == False: print(userCookieDir, "폴더가 없어서 생성함") os.mkdir(userCookieDir) options.add_argument(f"user-data-dir={userCookieDir}") options.add_argument(f'--user-agent={UA}') options.add_argument(f'--window-size={width}, {height}') driver = webdriver.Chrome(options=options) driver.execute_cdp_cmd("Network.setUserAgentOverride", UA_Data) driver.get('https://google.com') driver.set_window_position(500, 500) input()

  • 웹-크롤링
  • selenium
  • cdp
packet 댓글 2 좋아요 1 조회수 2389

insta_web 질문 있습니다!

미해결

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

안녕하세요! 선생님 혹시 에러가 나는데 봐주실 수 있을까요 ㅠㅠ 기본적으로 로그인부터 안됩니다 ㅠㅠ 에러 DevTools listening on ws://127.0.0.1:51221/devtools/browser/d2c4970f-37a8-4257-ad60-95407a9b0e45 cannot access local variable 'actions' where it is not associated with a value [에러] insta_web_login > 에러 발생 Traceback (most recent call last): File "c:\Users\문소희\Desktop\project\insta_auto\main.py", line 25, in <module> insta_web.insta_web_work(driver,keyword,count) File "c:\Users\문소희\Desktop\project\insta_auto\insta_web.py", line 117, in insta_web_work insta_web_link_extract(driver,count) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\문소희\Desktop\project\insta_auto\insta_web.py", line 75, in insta_web_link_extract WebDriverWait(driver, 10).until(EC.presence_of_element_located( File "C:\Users\문소희\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\support\wait.py", line 95, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Stacktrace: Backtrace: GetHandleVerifier [0x01086E73+48323] (No symbol) [0x01019661] (No symbol) [0x00F25308] (No symbol) [0x00F50B45] (No symbol) [0x00F50CDB] (No symbol) [0x00F7E3D2] (No symbol) [0x00F6A924] (No symbol) [0x00F7CAC2] (No symbol) [0x00F6A6D6] (No symbol) [0x00F4847C] (No symbol) [0x00F4957D] GetHandleVerifier [0x012EFD5D+2575277] GetHandleVerifier [0x0132F86E+2836158] GetHandleVerifier [0x013296DC+2811180] GetHandleVerifier [0x011141B0+626688] (No symbol) [0x0102314C] (No symbol) [0x0101F4B8] (No symbol) [0x0101F59B] (No symbol) [0x010121B7] BaseThreadInitThunk [0x76A100C9+25] RtlGetAppContainerNamedObjectPath [0x77907B4E+286] RtlGetAppContainerNamedObjectPath [0x77907B1E+238] main import time import uiautomator2 as u2 from selenium import webdriver import insta_web import insta_mobile serial = "ce031713db01712d02" device = u2.connect(serial) options = webdriver.ChromeOptions() options.add_argument('--user-agent= Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36') options.add_argument("--disanble-logging") options.add_experimental_option("useAutomationExtension",False) options.add_experimental_option('excludeSwitches',["enable-auttomation"]) driver = webdriver.Chrome(options=options) keyword_list = ["골린이", "골프사랑", "골프중독","골프스윙", "골프레슨"] for keyword in keyword_list: keyword = keyword.replace(" ","") count = 1000 insta_web.insta_web_work(driver,keyword,count) insta_mobile.insta_mobile_work(device) insta_web import time, data import chromedriver_autoinstaller chromedriver_autoinstaller.install() from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys from selenium.webdriver import ActionChains import pyperclip def insta_web_login(driver): try: driver.get("https://www.instagram.com/") # time.sleep(2) id_selector = "#loginForm > div > div:nth-child(1) > div > label > input" WebDriverWait(driver, 10).until(EC.presence_of_element_located( (By.CSS_SELECTOR, id_selector) )) id_input = driver.find_element(By.CSS_SELECTOR,id_selector) id_input.click() time.sleep(5) # ctrl + c 동작 pyperclip.copy(data.id) # ctrl + v 동작 actions.key_down(Keys.CONTROL).send_keys('v').key_up(Keys.CONTROL).perform() # id_input.send_keys(data.id) time.sleep(5) pw_selector = "#loginForm > div > div:nth-child(2) > div > label > input" pw_input = driver.find_element(By.CSS_SELECTOR,pw_selector) pw_input.click() time.sleep(5) actions = ActionChains(driver) # ctrl + c 동작 pyperclip.copy(data.pw) # ctrl + v 동작 actions.key_down(Keys.CONTROL).send_keys('v').key_up(Keys.CONTROL).perform() time.sleep(5) login_btn_selector = "#loginForm > div > div:nth-child(3) > button" login_btn = driver.find_element(By.CSS_SELECTOR, login_btn_selector) login_btn.click(5) except Exception as e: print(e) print('[에러] insta_web_login > 에러 발생') def insta_web_hashtag_search(driver,keyword): try: time.sleep(50) from urllib import parse keyword = "골프사랑" keyword = parse.quote(keyword) driver.get(f"https://www.instagram.com/explore/tags/{keyword}/") except Exception as e: print(e) print["[에러] insta_web_hashtag_search > 해시태그 검색중 에러 발생"] def insta_web_link_extract(driver, count=100): time.sleep(5) all_posting_sel = "div[id^='mount_0_0'] > div > div > div.x9f619.x1n2onr6.x1ja2u2z > div > div > div > div.x78zum5.xdt5ytf.x10cihs4.x1t2pt76.x1n2onr6.x1ja2u2z > div.x9f619.xnz67gz.x78zum5.x168nmei.x13lgxp2.x5pf9jr.xo71vjh.x1uhb9sk.x1plvlek.xryxfnj.x1c4vz4f.x2lah0s.x1q0g3np.xqjyukv.x1qjc9v5.x1oa3qoh.x1qughib > div.xh8yej3.x1gryazu.x10o80wk.x14k21rp.x1porb0y.x17snn68.x6osk4m > section > main > article > div:nth-child(3) > div" WebDriverWait(driver, 10).until(EC.presence_of_element_located( (By.CSS_SELECTOR, all_posting_sel) )) all_posting_box = driver.find_element(By.CSS_SELECTOR, all_posting_sel) time.sleep(5) '''링크 100개 추출''' links = [] while len(links) < count : try: for _ in range(6): driver.execute_script("window.scrollBy(0,600);") time.sleep(5) all_posting_box = driver.find_element(By.CSS_SELECTOR, all_posting_sel) posk_links = all_posting_box.find_elements(By.TAG_NAME,"a") for eachLink in posk_links: link = eachLink.get_attribute('href') links.append(link) links = set(links) links = list(links) except Exception as e: print(e) print("insta_web_link_extract > while 에러 발생") with open('links.txt',"a") as f: for link in links: # print(link) f.write(f"{link}\n") def insta_web_work(driver,keyword,count): insta_web_login(driver) insta_web_hashtag_search(driver, keyword) insta_web_link_extract(driver, count) insta_ mobile import time, data import chromedriver_autoinstaller chromedriver_autoinstaller.install() from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys from selenium.webdriver import ActionChains import pyperclip def insta_web_login(driver): try: driver.get("https://www.instagram.com/") # time.sleep(2) id_selector = "#loginForm > div > div:nth-child(1) > div > label > input" WebDriverWait(driver, 10).until(EC.presence_of_element_located( (By.CSS_SELECTOR, id_selector) )) id_input = driver.find_element(By.CSS_SELECTOR,id_selector) id_input.click() time.sleep(5) # ctrl + c 동작 pyperclip.copy(data.id) # ctrl + v 동작 actions.key_down(Keys.CONTROL).send_keys('v').key_up(Keys.CONTROL).perform() # id_input.send_keys(data.id) time.sleep(5) pw_selector = "#loginForm > div > div:nth-child(2) > div > label > input" pw_input = driver.find_element(By.CSS_SELECTOR,pw_selector) pw_input.click() time.sleep(5) actions = ActionChains(driver) # ctrl + c 동작 pyperclip.copy(data.pw) # ctrl + v 동작 actions.key_down(Keys.CONTROL).send_keys('v').key_up(Keys.CONTROL).perform() time.sleep(5) login_btn_selector = "#loginForm > div > div:nth-child(3) > button" login_btn = driver.find_element(By.CSS_SELECTOR, login_btn_selector) login_btn.click(5) except Exception as e: print(e) print('[에러] insta_web_login > 에러 발생') def insta_web_hashtag_search(driver,keyword): try: time.sleep(50) from urllib import parse keyword = "골프사랑" keyword = parse.quote(keyword) driver.get(f"https://www.instagram.com/explore/tags/{keyword}/") except Exception as e: print(e) print["[에러] insta_web_hashtag_search > 해시태그 검색중 에러 발생"] def insta_web_link_extract(driver, count=100): time.sleep(5) all_posting_sel = "div[id^='mount_0_0'] > div > div > div.x9f619.x1n2onr6.x1ja2u2z > div > div > div > div.x78zum5.xdt5ytf.x10cihs4.x1t2pt76.x1n2onr6.x1ja2u2z > div.x9f619.xnz67gz.x78zum5.x168nmei.x13lgxp2.x5pf9jr.xo71vjh.x1uhb9sk.x1plvlek.xryxfnj.x1c4vz4f.x2lah0s.x1q0g3np.xqjyukv.x1qjc9v5.x1oa3qoh.x1qughib > div.xh8yej3.x1gryazu.x10o80wk.x14k21rp.x1porb0y.x17snn68.x6osk4m > section > main > article > div:nth-child(3) > div" WebDriverWait(driver, 10).until(EC.presence_of_element_located( (By.CSS_SELECTOR, all_posting_sel) )) all_posting_box = driver.find_element(By.CSS_SELECTOR, all_posting_sel) time.sleep(5) '''링크 100개 추출''' links = [] while len(links) < count : try: for _ in range(6): driver.execute_script("window.scrollBy(0,600);") time.sleep(5) all_posting_box = driver.find_element(By.CSS_SELECTOR, all_posting_sel) posk_links = all_posting_box.find_elements(By.TAG_NAME,"a") for eachLink in posk_links: link = eachLink.get_attribute('href') links.append(link) links = set(links) links = list(links) except Exception as e: print(e) print("insta_web_link_extract > while 에러 발생") with open('links.txt',"a") as f: for link in links: # print(link) f.write(f"{link}\n") def insta_web_work(driver,keyword,count): insta_web_login(driver) insta_web_hashtag_search(driver, keyword) insta_web_link_extract(driver, count)

  • python
  • selenium
김기솔 댓글 3 좋아요 1 조회수 1678

"쿠팡 제품 검색 결과 크롤링" 강의를 응용해서 타오바오 사이트에서 해보려고 하는데,,

미해결

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

"쿠팡 제품 검색 결과 크롤링" 강의를 응용해서 타오바오 사이트에서 해보려고 하는데, 자꾸 안돼서 아래와 같이 print(html) 했더니 뭔가 차단된거 같은 html 막 쭉 뜨네요 이럴때는 어떻게 해야하나요? req = requests.get(links, timeout=5, headers=headers, cookies=cookie) html = req.text soup = BeautifulSoup(html, "html.parser") print(html)

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
울랄라 댓글 2 좋아요 0 조회수 1012

database is locked.

미해결

실리콘밸리 엔지니어가 가르치는 파이썬 장고 웹프로그래밍

sqliteBrowser 사용하는 수업에서 db.sqlite3를 열려고 하니, database is locked 라는 메시지가 뜹니다. 그래서 ChatGPT나 Bard... Googling을 이용해봤지만, 저에게 해당될만한 내용이 없네요. 혹시 몰라 재부팅도 해봤습니다. 이거 DB부분만 지웠다가 다시 까는 방법이 있을까요? (makemigrations, migrate 부분)

  • python
  • django
  • bootstrap
  • rest-api
  • drf
bigseoul 댓글 3 좋아요 1 조회수 2710

섹션6-3 '댓글' 질문드립니다!

미해결

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

섹션 6-3에서 for word in "멘트" << 이렇게 돌리면 댓글이 한글자씩 입력하고 작성됩니다. ex) 멘트 댓글1 : 멘 댓글2 : 트 if not device(text="이 게시물에 대한 댓글 기능이 제한되었습니다.").exists(): print("커멘드 작성 가능 exists") device(resourceId=" com.instagram.android :id/layout_comment_thread_edittext").click() for word in "안녕하세요!": device.send_keys(word) time.sleep(random.uniform(0.03,0.08)) time.sleep(5) device(resourceId=" com.instagram.android :id/layout_comment_thread_post_button_click_area").click() time.sleep(2) device.press ('back') time.sleep(2) device.press ('back') if not device(text="이 게시물에 대한 댓글 기능이 제한되었습니다.").exists(): print("커멘드 작성 가능 exists") device(resourceId="com.instagram.android:id/layout_comment_thread_edittext").click() for word in "안녕하세요!": device.send_keys(word) time.sleep(random.uniform(0.03,0.08)) time.sleep(5) device(resourceId="com.instagram.android:id/layout_comment_thread_post_button_click_area").click() time.sleep(2) device.press('back') time.sleep(2) device.press('back')

  • python
  • selenium
김기솔 댓글 2 좋아요 1 조회수 381

회귀 실습 중 rmse 결과값 질문

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

안녕하세요 선생님 현재 모델링 및 평가(회귀)부분을 학습하고 있습니다. 코드를 따라가면서 실습을 진행하고 있는데, rmse 값이 선생님과 달라 질문 드립니다. 제가 알기로는 모델링을 하는 과정에서 예측한 값이 달라질 수 있고, 이에 따라 평가지표인 rmse 값이 다를 수 있다...라고 알고 있습니다. 그런데 값의 차이 뿐만이 아니라 baseline과 scaler 적용 결과가 좋은지 나쁜지가 달라 질문드립니다. 예를 들어, 선생님께서 하셨을때는 RandomForestRegressor의 baseline이 rmse값이 가장 좋았고(작았고), scaler를 적용했을 때 rmse가 커져서 scaler 적용은 하지 않는게 좋다~라는 내용의 실습이었는데 제가 했을 때는 baseline의 rmse보다 scaler를 적용했을 때의 rmse가 작아 scaler를 적용하는 것이 좋다..는 결론이 나옵니다. 질문을 정리하자면, 모델링을 하는 과정에서 선생님과 제가 실습한 예측값과 rmse가 다른게 맞는지 다른게 맞다 해도 scaler 적용여부 등을 바꿀 수 있을 정도로 예측값과 rmse가 달라질 수 있는지 (추가질문)달라지더라도 선생님 실습값 : 4728.xx 제 실습값 6025.174022213681 이정도로 달라질 수 있는지... (추가질문) 모델링 및 평가(회귀) 24:56에서 수험자는 알 수 없는 영역>y_test로 rmse로 구하시고 결과값이 17909.xx로 나왔는데 여기에서도 charges에 로그변환 한 이후기 떄문에 원래는 np.exp(pred)로 rmse를 구했어야 하는지 일 것 같습니다. 감사합니다.

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
콘스트 댓글 1 좋아요 1 조회수 709

soup으로 검색한 버튼 또는 text를 click할때 어떻게 하나요 ?

미해결

파이썬 무료 강의 (활용편3) - 웹 스크래핑 (5시간)

webdriver의 find_element로 찾은 경우 .click()을 붙여주면 click이 되는데, soup으로 찾은 경우 .click()을 붙여주면 오류가 발생하네요. click을 하려면 find_element를 써야 할까요? soup으로 찾은 객체는 click을 할 수 없을까요?

  • python
  • 웹-크롤링
  • selenium
  • 웹-스크래핑
이민호 댓글 1 좋아요 1 조회수 3585

해시태그 추출

미해결

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

로그인 > 해시태그 검색 까지는 작동되는데... 이후 스크롤부터 링크 추출까지 막혔습니다. 어떤 문제가 있는지 알수 있을까요? --------------------------------------------------------- import time import chromedriver_autoinstaller chromedriver_autoinstaller.install() from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support .ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys from selenium.webdriver import ActionChains driver = webdriver.Chrome () driver.get(" https://www.instagram.com/ ") # time.sleep(2) id_selector = "#loginForm > div > div:nth-child(1) > div > label > input" WebDriverWait(driver, 10).until(EC.presence_of_element_located( (By.CSS_SELECTOR, id_selector) )) import mdata id_input = driver.find_element(By.CSS_SELECTOR,id_selector) id_input.send_keys( mdata.id ) time.sleep(1) pw_selector = "#loginForm > div > div:nth-child(2) > div > label > input" pw_input = driver.find_element(By.CSS_SELECTOR,pw_selector) pw_input.send_keys( mdata.pw ) time.sleep(1) login_btn_selector = "#loginForm > div > div:nth-child(3) > button" login_btn = driver.find_element(By.CSS_SELECTOR, login_btn_selector) login_btn.click() time.sleep(10) from urllib import parse keyword = "사업가" keyword = parse.quote(keyword) driver.get(f" https://www.instagram.com/explore/tags/{keyword}/ ") time.sleep(10) all_posting_sel = "div[id^='mount_0_0'} > div > div > div.x9f619.x1n2onr6.x1ja2u2z > div > div > div > div.x78zum5.xdt5ytf.x10cihs4.x1t2pt76.x1n2onr6.x1ja2u2z > div.x9f619.xnz67gz.x78zum5.x168nmei.x13lgxp2.x5pf9jr.xo71vjh.x1uhb9sk.x1plvlek.xryxfnj.x1c4vz4f.x2lah0s.x1q0g3np.xqjyukv.x1qjc9v5.x1oa3qoh.x1qughib > div.xh8yej3.x1gryazu.x10o80wk.x14k21rp.x1porb0y.x17snn68.x6osk4m > section > main > article > div:nth-child(3) > div" time.sleep(3) all_posting_box = driver.find_element(By.CSS_SELECTOR, all_posting_sel) time.sleep(3) '''링크 100개 추출''' links = [] while len(links) < 100 : for _ in range(6): driver.execute_script("window.scrollBy(0.600);") time.sleep(1) all_posting_box = driver.find_element(By.CSS_SELECTOR, all_posting_sel) posk_links = all_posting_box.find_elements(By.TAG_NAME,"a") for eachLink in posk_links: link = eachLink.get_attribute('href') links.append(link) links = set(links) links = list(links) for link in links: print(link) print("******") print(len(links), "개의 링크를 추출") input() ------------------------------------------------------ DevTools listening on ws://127.0.0.1:50287/devtools/browser/ed0f17f2-033d-4ba2-80b8-8f3d2f886171 Traceback (most recent call last): File "c:\Users\문소희\Desktop\project\insta_auto\insta_web.py", line 50, in <module> all_posting_box = driver.find_element(By.CSS_SELECTOR, all_posting_sel) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\문소희\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 831, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\문소희\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute self.error_handler.check_response(response) File "C:\Users\문소희\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: An invalid or illegal selector was specified (Session info: chrome=113.0.5672.127) Stacktrace: Backtrace: GetHandleVerifier [0x005C6DF3+48691] (No symbol) [0x00558CC1] (No symbol) [0x00465068] (No symbol) [0x00468401] (No symbol) [0x00469641] (No symbol) [0x004696E0] (No symbol) [0x004900D0] (No symbol) [0x004906AB] (No symbol) [0x004BDD62] (No symbol) [0x004AA314] (No symbol) [0x004BC452] (No symbol) [0x004AA0C6] (No symbol) [0x00487E18] (No symbol) [0x00488F3D] GetHandleVerifier [0x00824EAA+2531050] GetHandleVerifier [0x00864B60+2792352] GetHandleVerifier [0x0085E6EC+2766636] GetHandleVerifier [0x00650820+612448] (No symbol) [0x005625BC] (No symbol) [0x0055E808] (No symbol) [0x0055E8EB] (No symbol) [0x00551C77] BaseThreadInitThunk [0x754900C9+25] RtlGetAppContainerNamedObjectPath [0x772E7B4E+286] RtlGetAppContainerNamedObjectPath [0x772E7B1E+238]

  • python
  • selenium
김기솔 댓글 1 좋아요 1 조회수 774

쿠팡정보 웹사이트 관련,

미해결

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

선생님! 쿠팡정보 크롤링해서 웹사이트 만들었습니다 이렇게 유익한 강의 처음입니다!! 너무너무 감사해요 다름이 아니라 혹시 괜찮으시면 선생님과 만든 웹사이트에 쿠팡 파트너스 API 연동시키는 부분 강의로 찍어주실수 있는지요 아님 유튜브 영상이라도 부탁드려요 ㅠㅠㅠ 혼자 하려니까 API 주소를 어따 붙여넣기 해야하는지 감이 안잡히네요

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
울랄라 댓글 1 좋아요 0 조회수 320

인스타그램 로그인 완료 후 검색 부분 (섹션 5 -3)

미해결

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

강의에 보여주시는 부분과 다른 디자인으로 변경되었습니다. 비슷한 방법으로 해봐도 도저히 실행되지가 않네요..

  • python
  • selenium
김기솔 댓글 1 좋아요 1 조회수 438

네이버 메일 자동화, 메일 창이 새탭에 생성

미해결

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

네이버 메일 자동화 하는 강의를 듣는중 입니다. 네이버 화면이 변경되면서, 네이버 메일을 누르면 기존 구글 탭에서 네이버 메일로 가는게 아닌, 새로운 탭에 네이버 메일이 생성됩니다. 때문에, 메일쓰기 버튼을 클릭하라고 해도 NoSuchElementException 에러가 발생합니다. (이게 네이버 메일이 새 탭에서 생성되었기 때문이라는 것을 알게되기 까지 정말 힘들었습니다...) 파이썬으로 제어하는 창을 활성화 탭으로 옮기도록 driver.switch_to.window(driver.window_handles[-1]) 하면 가능하다는 건 알게되었습니다. 하지만, 내가 지금 바라보고 있는 탭이 어떤 탭인지 알 수 있는 방법이 무엇인지 알고싶습니다.

  • python
  • selenium
akanto1 댓글 1 좋아요 0 조회수 937

파이썬 합계 오류

미해결

파이참으로 100~200 까지 3의 배수 인쇄하고, 그의 합 구하고 있는데 3의 배수 5개씩 인쇄는 잘 했는데 합계가 이상하게 구해집니다. 오류가 어디에 있는 건지 모르겠어요.. 고치면 오류떠서 아예 실행이 안되는데 ㅜㅜ for문이랑 while문 두개로 만들고 있는데 둘다 합계만 이상하게 뜹니다. ㅠ <<for문>> a = 0 hap = 0 count = 0 for a in range(100, 201) : if a % 3 == 0 : print(a) count = count + 1 if count % 5 == 0 : print() a = a + 1 hap = hap + a print("100~200 중 3의 배수의 합 : %d" % hap) <<while문>> a = 100 count = 0 hap = 0 while a <= 200 : if a % 3 == 0 : print(a) count = count + 1 if count % 5 == 0 : print() a = a + 1 hap = hap + a print("100~200 중 3의 배수의 합 : %d" % hap)

  • 파이썬
  • python
열공123 댓글 1 좋아요 0 조회수 422

네이버가 바뀌었는데 카테고리? 리스트 가져오는게 안되네요?

미해결

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

안녕하세요. 강의 잘 듣고 있습니다. 네이버가 새로운 형태로 바뀌었는데 아주 간단한 것이 해결이 안되네요? 이유가 뭘까요? 기본구조는 이렇게 생겼습니다. <li class="shortcut_item"> <a href="mail.naver.com" class="link_service"> <span class="service_icon type_mail"> ::before ::after </span> <span class="service_name">메일</span> </a> </li> <li class="shortcut_item"> </li> 아래처럼 너무 단순한거라 생각했던 것을 못 가져오네요? 확인 부탁드려요~ service_name = soup.find(class_="service_name", string="메일") print(service_name) # None 출력이 안되네 이유가 뭘까나? print()

  • python
  • 웹-크롤링
  • selenium
  • beautifulsoup
jangtaesan 댓글 2 좋아요 1 조회수 606

인기 태그

인프런 TOP Writers

주간 인기글