172만명의 커뮤니티!! 함께 토론해봐요.
해결됨
실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용
현재 네이버 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
2023-07-03T08:18:48.617Z
댓글 1
좋아요 1
조회수 338
해결됨
실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용
현재 강의는 "네이버 view탭 검색결과 크롤링 2" 이며 00:46 지점입니다. 계속 ".total_area"를 선택하고 for 문도 강의에서랑 똑같이 작성해서 실행하는데 출력이 안나옵니다. 어디를 고쳐야할까요 ?
python 웹-크롤링 selenium beautifulsoup
jtk5648
2023-07-03T04:43:42.478Z
댓글 1
좋아요 1
조회수 392
미해결
실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용
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
2023-06-29T12:59:10.239Z
댓글 1
좋아요 0
조회수 1419
미해결
[자동화 완전 정복] 인스타그램 휴대폰, 웹 자동화 프로그램 개발
Web 태그 접속후, 최근 사진 영역이 없습니다.
lin1005
2023-06-29T10:38:46.602Z
댓글 2
좋아요 0
조회수 409
미해결
실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용
from selenium import webdriver import time driver = webdriver.Chrome() driver.get("https://google.com") time.sleep(2) #2. 알아서 버전업을 해줌 별다른 반응이 없네요 ㅠ 맥북은
python 웹-크롤링 selenium beautifulsoup
gksmf9898
2023-06-29T08:12:30.644Z
댓글 1
좋아요 0
조회수 304
미해결
실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용
강의 내용 외 개인적인 실습 사이트의 질문은 답변이 제공되지 않습니다. 문제가 생긴 코드, 에러 메세지 등을 꼭 같이 올려주셔야 빠른 답변이 가능합니다. 답변은 바로 제공되지 않을 수 있습니다. 실력 향상을 위해서는 직접 고민하고 검색해가며 해결하는 게 가장 좋습니다. 셀레니움으로 알리익스프레스 로그인하려고 xpath 따서 해봐도 잘안되네요……
python 웹-크롤링 selenium beautifulsoup
에너자이저
2023-06-29T01:02:01.854Z
댓글 1
좋아요 0
조회수 313
미해결
실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용
첨부대로 따라하고 실행 후 input값 입력하면 저렇게 [] 리스트만 출력되거나, 아예 아무것도 나타나지 않아요. 뭐가 문제일까요?
python 웹-크롤링 selenium beautifulsoup
날치알한판
2023-06-28T05:04:14.815Z
댓글 2
좋아요 0
조회수 870
미해결
Selenium 기본 과정
BY.xpath, "./.." 방법으로 부모값을 가져오는 방법에 대해 알려주셨는데요 반대로 자녀 값을 가져오는 방법도 있을가요?
최민호
2023-06-27T02:57:48.638Z
댓글 1
좋아요 1
조회수 431
미해결
Selenium 기본 과정
맥에서 가상환경 활성화 하는 방법을 알고싶습니다
wsws
2023-06-23T06:31:21.975Z
댓글 1
좋아요 1
조회수 465
미해결
실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용
쓱닷컴 이벤트 주소는 아래와같습니다. 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
가후
2023-06-20T13:42:41.700Z
댓글 1
좋아요 0
조회수 316
미해결
[자동화 완전 정복] 인스타그램 휴대폰, 웹 자동화 프로그램 개발
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()
김기솔
2023-06-12T09:06:25.852Z
댓글 2
좋아요 1
조회수 342
미해결
[신규 개정판] 이것이 진짜 엑셀자동화다 - 기본편
좋은강의 감사드립니다. 덕분에 파이참설치했다가 Vscode로 갈아탔습니다. 다만 인터넷이 안되는 회사PC에서 업무자동화를 구현하려고 다양한 방법으로 pip install pyautogui를 설치하려고 해보았는데요 pip install pyautogui 를 실행하면 아래(이미지1)같이 뜨구요(아마 인터넷안되서 그런거아닌가 싶습니다만) 이미지1) 그래서 인터넷되는 피씨에서 pip install pyautogui 실행후 whl를 다운받아서 복사를 해놔도 import pyautogui가 실행이 되지는 않았구요 아래(이미지2)처럼 압축파일을 실행해도 작동하지는 않습니다. 이미지2 아래(이미지3)처럼 pip install 압축파일 을 실행해도 안되었습니다. 이미지2) 인터넷이 안되는곳에서 설치를 불가능한 것일까요?
intenet1
2023-06-12T05:56:12.485Z
댓글 2
좋아요 0
조회수 1273
미해결
파이썬 셀레니움 고급편 (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()
packet
2023-06-07T09:06:59.038Z
댓글 2
좋아요 1
조회수 2389
미해결
[자동화 완전 정복] 인스타그램 휴대폰, 웹 자동화 프로그램 개발
안녕하세요! 선생님 혹시 에러가 나는데 봐주실 수 있을까요 ㅠㅠ 기본적으로 로그인부터 안됩니다 ㅠㅠ 에러 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)
김기솔
2023-06-05T10:01:09.007Z
댓글 3
좋아요 1
조회수 1675
미해결
실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용
"쿠팡 제품 검색 결과 크롤링" 강의를 응용해서 타오바오 사이트에서 해보려고 하는데, 자꾸 안돼서 아래와 같이 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
울랄라
2023-06-04T23:09:28.318Z
댓글 2
좋아요 0
조회수 1012
미해결
[자동화 완전 정복] 인스타그램 휴대폰, 웹 자동화 프로그램 개발
섹션 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')
김기솔
2023-05-31T10:04:55.546Z
댓글 2
좋아요 1
조회수 380
미해결
파이썬 무료 강의 (활용편3) - 웹 스크래핑 (5시간)
webdriver의 find_element로 찾은 경우 .click()을 붙여주면 click이 되는데, soup으로 찾은 경우 .click()을 붙여주면 오류가 발생하네요. click을 하려면 find_element를 써야 할까요? soup으로 찾은 객체는 click을 할 수 없을까요?
python 웹-크롤링 selenium 웹-스크래핑
이민호
2023-05-28T00:46:08.744Z
댓글 1
좋아요 1
조회수 3580
미해결
[자동화 완전 정복] 인스타그램 휴대폰, 웹 자동화 프로그램 개발
로그인 > 해시태그 검색 까지는 작동되는데... 이후 스크롤부터 링크 추출까지 막혔습니다. 어떤 문제가 있는지 알수 있을까요? --------------------------------------------------------- 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]
김기솔
2023-05-25T09:21:38.021Z
댓글 1
좋아요 1
조회수 773
미해결
실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용
선생님! 쿠팡정보 크롤링해서 웹사이트 만들었습니다 이렇게 유익한 강의 처음입니다!! 너무너무 감사해요 다름이 아니라 혹시 괜찮으시면 선생님과 만든 웹사이트에 쿠팡 파트너스 API 연동시키는 부분 강의로 찍어주실수 있는지요 아님 유튜브 영상이라도 부탁드려요 ㅠㅠㅠ 혼자 하려니까 API 주소를 어따 붙여넣기 해야하는지 감이 안잡히네요
python 웹-크롤링 selenium beautifulsoup
울랄라
2023-05-25T02:49:39.323Z
댓글 1
좋아요 0
조회수 318
미해결
[자동화 완전 정복] 인스타그램 휴대폰, 웹 자동화 프로그램 개발
강의에 보여주시는 부분과 다른 디자인으로 변경되었습니다. 비슷한 방법으로 해봐도 도저히 실행되지가 않네요..
김기솔
2023-05-24T09:24:12.252Z
댓글 1
좋아요 1
조회수 433