IT Studio/개발
[파이썬] 인스타 좋아요 봇 다시 만들기
유영훈
2021. 12. 14. 19:54
https://hoonstudio.tistory.com/303?category=882469
기존에 인스타 좋아요 봇을 어느정도 만들었는데, 노트북을 SSD로 교체하면서 기존 파일 백업이 제대로 안되었나보다.
그래서 HDD를 다시 꽂아서 복사하기 보다는 기존 내 포스팅을 참고해서 다시 코딩을 해보려고 한다.
어차피 파이썬도 안쓰는 동안 많이 잊어서 공부하는 겸사겸사 하려고 한다. (속으로는 백업의 중요성을 다시 깨달았다)
pycharm에서 pip도 실행할 수 있도록 pip를 설치하였다.
노란색 코멘트는 pip 21.3.1 버전 사용가능하다는 레코멘드.
chromedriver는 직접 더블클릭으로 설치가 아닌 selenium에서 바라보는 경로를 지정해주어야 한다.
그렇지 않으면 아래와 같이 에러가 나온다.
D:\05.Lab\02.python\20211214_insta_like_bot\main.py:24: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
driver = webdriver.Chrome(driver_path, options=options)
Traceback (most recent call last):
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\move_\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 947, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\move_\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1416, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 지정된 파일을 찾을 수 없습니다
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\05.Lab\02.python\20211214_insta_like_bot\main.py", line 81, in <module>
bot()
File "D:\05.Lab\02.python\20211214_insta_like_bot\main.py", line 24, in bot
driver = webdriver.Chrome(driver_path, options=options)
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 90, in __init__
self.service.start()
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
Process finished with exit code 1
나의 경우에는 main.py 파일이 있는 동일 경로에 chromedriver 파일을 복사해두었다.
그랬더니 예전에는 보지 못하였던 새로운 에러가 떨어졌다.
D:\05.Lab\02.python\20211214_insta_like_bot\main.py:24: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
driver = webdriver.Chrome(driver_path, options=options)
로그인중....
D:\05.Lab\02.python\20211214_insta_like_bot\main.py:35: DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
id_input = driver.find_element_by_xpath('//*[@id="loginForm"]/div/div[1]/div/label')
D:\05.Lab\02.python\20211214_insta_like_bot\main.py:40: DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
pw_input = driver.find_element_by_xpath('//*[@id="loginForm"]/div/div[2]/div/label')
D:\05.Lab\02.python\20211214_insta_like_bot\main.py:45: DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
login_btn = driver.find_element_by_xpath('//*[@id="loginForm"]/div/div[3]/button')
D:\05.Lab\02.python\20211214_insta_like_bot\main.py:56: DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
first_feed = driver.find_element_by_xpath('//*[@id="react-root"]/section/main/article/div[1]/div/div/div[1]/div[1]/a/div/div[2]')
Traceback (most recent call last):
File "D:\05.Lab\02.python\20211214_insta_like_bot\main.py", line 81, in <module>
bot()
File "D:\05.Lab\02.python\20211214_insta_like_bot\main.py", line 56, in bot
first_feed = driver.find_element_by_xpath('//*[@id="react-root"]/section/main/article/div[1]/div/div/div[1]/div[1]/a/div/div[2]')
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 520, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 1244, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 422, in execute
response = self.command_executor.execute(driver_command, params)
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 421, in execute
return self._request(command_info[0], url, body=data)
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 443, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\urllib3\request.py", line 78, in request
return self.request_encode_body(
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\urllib3\request.py", line 170, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\urllib3\poolmanager.py", line 375, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\urllib3\connectionpool.py", line 445, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "D:\05.Lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\urllib3\connectionpool.py", line 440, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\move_\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1347, in getresponse
response.begin()
File "C:\Users\move_\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 307, in begin
version, status, reason = self._read_status()
File "C:\Users\move_\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Users\move_\AppData\Local\Programs\Python\Python39\lib\socket.py", line 704, in readinto
return self._sock.recv_into(b)
KeyboardInterrupt
Process finished with exit code -1073741510 (0xC000013A: interrupted by Ctrl+C)
https://velog.io/@sangyeon217/deprecation-warning-executablepath-has-been-deprecated
아래처럼 취소선이 왜 생겼는지 보니 selenium 버전이 4버전이 되면서 라이브러리가 변경되서 warning도 뜨고 한다고 함. 그래서 기존대로 3버전으로 낮추는 작업을 진행함.
PS D:\05.Lab\02.python\20211214_insta_like_bot> pip uninstall selenium
Found existing installation: selenium 4.1.0
Uninstalling selenium-4.1.0:
Would remove:
d:\05.lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\selenium-4.1.0.dist-info\*
d:\05.lab\02.python\20211214_insta_like_bot\venv\lib\site-packages\selenium\*
pip를 3버젼대로 설치하고나니 취소선이 다시 없어짐
PS D:\05.Lab\02.python\20211214_insta_like_bot> pip3 install selenium=3.141
ERROR: Invalid requirement: 'selenium=3.141'
Hint: = is not a valid operator. Did you mean == ?
WARNING: You are using pip version 21.1.2; however, version 21.3.1 is available.
Collecting selenium==3.141
Downloading selenium-3.141.0-py2.py3-none-any.whl (904 kB)
|████████████████████████████████| 904 kB 6.4 MB/s
Requirement already satisfied: urllib3 in d:\05.lab\02.python\20211214_insta_like_bot\venv\lib\site-packages (from
selenium==3.141) (1.26.7)
Installing collected packages: selenium
Successfully installed selenium-3.141.0
WARNING: You are using pip version 21.1.2; however, version 21.3.1 is available.
You should consider upgrading via the 'D:\05.Lab\02.python\20211214_insta_like_bot\venv\Scripts\python.exe -m pip i
nstall --upgrade pip' command.
너무 길어져서 다음 포스팅으로 이어서 진행하겠다.