Web_Python

miin·2021년 8월 12일
0

Python

목록 보기
8/10

wep scrapper은 웹 상의 데이터를 추출하는것을 의미

requests 모듈 참고자료
https://dgkim5360.tistory.com/entry/python-requests

url을 가져오기
requests.get("http:....") / 패키지 requests 설치 -> import requests -> 변수선언

변수.find("div", {"class": "pagination"}) //class명이 pagination인 div를 찾음
변수.find_all('a') // anchor을 모두 찾아줌

html에있는 text모두 가져오기
print(indeed_result.text)

soup : 데이터 추출담당

pagination = indeed_soup.find("div", {"class":"pagination"})
#indeed_soup의 find를 써서 찾은결과를 pagination변수에 넣어줌

for link in links[:-1]:# 마지막에 next라는 문자때문에 -1 해줌
#print(page.find("span"))#a안에있는 span 가져오기
#spans.append(link.find("span"))
#pages.append(link.find("span").string)#text만 가져오기
pages.append(int(link.string))#숫자로 형변환함
find_all 전부찾음
find 첫번째것만 찾음

0개의 댓글