더보기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
from selenium import webdriver
import codecs
import re
options = webdriver.ChromeOptions()
options.add_argument('headless')
options.add_argument('window-size=1920x1080')
options.add_argument("disable-gpu")
driver = webdriver.Chrome('chromedriver', chrome_options=options)
driver.get("https://comic.naver.com/webtoon/weekday.nhn")
driver.implicitly_wait(3)
text = driver.page_source
driver.quit()
p = re.compile('[\u3131-\u3163\uac00-\ud7a3]+')
text_sp = text.split("\n")
file_p = codecs.open("Webtoon_list.txt", "w", 'UTF-8')
for i in text_sp:
#print("[i] : " + str(i))
match = p.search(i)
if str(match) != "None":
#print("[" + str(count) + "]Webtoon Name : " + match.string)
if match.string.find('class=\"title\" title=') != -1:
final_text = match.string.split(">")[1].split("<")[0]
file_p.writelines(final_text + "\r\n")
file_p.close()
|
cs |
파이썬과 셀레니움을 이용해 네이버 웹툰의 이름을 긁어오는 프로그램이다.
셀레니움과 크롬 webdriver.exe를 이용했다.
chrome-driver.exe 파일은 Chrome Version : 86.0.4240.75 (86.0.X)에서 작동한다.
크롬 드라이버 파일과 크롬 버전이 호환이 되는 버전이어야 크롬 드라이버 프로그램을 사용 할 수 있다.
'개발, 연습' 카테고리의 다른 글
[파이썬] 맥에서 마우스 유틸 프로그램 편하게 켜기 (0) | 2021.06.04 |
---|---|
[파이썬] 파이썬 string 여러 형태 지정 (0) | 2021.04.28 |
[연습작] 파일 헥스뷰어 (0) | 2021.04.03 |
[재미] 아두이노 레오나르도 스타크래프트 매크로 (0) | 2021.03.17 |
vscode extension installation from VSIX (0) | 2020.12.20 |