Python 5

python + vscode = 이미지 크롤링-2

import urllib.request import lxml.html from bs4 import BeautifulSoup, element pageNum = 1 #저장할 이미지 경로 및 이름 (data폴더(없으면 만들어놓을것)에 face0.jpg 형식으로 저장) imageNum0 = 0 imageNum = 0 imageNum2 = 0 imageStr = "test_data/img" #url = "https://www.kr.playblackdesert.com/BeautyAlbum?searchType=0&searchText=&categoryCode=0&classType=0,4,8,12,16,20,21,24,25,26,28,31,27,19,23,11,29,17,5&Page=" base_url = "http:/..

Python 2021.08.02

python 크롤링 html type

from bs4 import BeautifulSoup html = '' \ ' ' \ ' 범죄도시' \ ' ' \ '' # 1. 조회 def ex1(): # 위의 html 문자열에 대해서, html 파싱하겠다. bs = BeautifulSoup(html, 'html.parser') print(bs, type(bs)) # 범죄도시 # a 태그 출력 tag = bs.a print(tag, type(tag)) # 범죄도시 # 2. Attribute 값 받아오기 def ex2(): bs = BeautifulSoup(html, 'html.parser') tag = bs.td print(tag['class']) # ['title'] => 리스트 print(tag['id']) # td1 print(tag.attrs)..

Python 2021.07.30

python + vscode = 이미지 크롤링

import urllib.request from bs4 import BeautifulSoup #아래의 코드를 실행하기 전 cmd명령어 로 lib 설치 먼저 해주어야함 #pip install requests #pip install bs4 # #[웹 이미지 첫번째 1장만 다운로드 받기] # #웹페이지의 소스를 가져온다. # url = "https://www.kr.playblackdesert.com/BeautyAlbum?searchType=0&searchText=&categoryCode=0&classType=0,4,8,12,16,20,21,24,25,26,28,31,27,19,23,11,29,17,5&Page=1" # fp = urllib.request.urlopen(url) # source = fp.read..

Python 2021.07.30