Programming/Python 웹 스크래퍼 만들기

Programming/Python 웹 스크래퍼 만들기

Python Keyword Arguments

5.5 Keyword Arguments 이전에 beautifulsoup 를 사용해서 class_ = "jobs" 에 해당하는 웹사이트 HTML 코드를 가져왔었다. from requests import get from bs4 import BeautifulSoup base_url = "https://weworkremotely.com/remote-jobs/search?utf8=%E2%9C%93&term=" search_term = "python" response = get(f'{base_url}{search_term}') if response.status_code != 200: print("Can't request website") else: soup = BeautifulSoup(response.text,'h..

Programming/Python 웹 스크래퍼 만들기

Python BeautifulSoup

5.4 BeautifulSoup 아래 코드로 weworkremotely 웹사이트의 python 구인정보를 가져왔다. from requests import get base_url = "https://weworkremotely.com/remote-jobs/search?utf8=%E2%9C%93&term=" search_term = "python" response = get(f'{base_url}{search_term}') if response.status_code != 200: print("Can't request website") else: print(response.text) jobs 라는 class 를 가진 section 을 찾아 추출한다. 그리고 section 에 있는 ul 안에서 모든 li 를 찾는..

Programming/Python 웹 스크래퍼 만들기

Python WebScrapper Introduction

5.1 Introduction 웹 스크래핑은 user가 쓴 코드가 웹사이트에 들어가서 데이터를 추출해내는 것이다. indeed.com ( 구인구직 사이트 ) 에서 검색할 수 있는 모든 프로그래밍 관련 일들의 데이터를 가져온다. 혹은 weworkremotely.com 에서 데이터를 가져올수도 있다. 그리고 이 모든 데이터들을 하나의 엑셀 파일에다 정리할수 도 있다. 웹 스크래핑을 통해 여러가지 정보를 수집할 수 있는데, 예를 들어 어떤 회사에 대한 기사들을 투자 정보를 얻기 위해 여러 웹사이트에서 가져올 수 도 있으며, 같은 제품을 판매하는 여러 웹사이트의 가격들 데이터를 수집하여 제일 싸게 구매 할 수 있는 곳을 선별할 수 도 있다. Python 과 Beautifulsoup 를 통해서 웹 스크래퍼를 제작..

Programming/Python 웹 스크래퍼 만들기

Python Requests, Get 복습

4.9 Recap for 반복문은 sequence 안의 각 item 으로 코드를 실행시킬 수 있는 방법이다. from requests import get websites = ( 'google.com', 'https://airbnb.com', 'facebook.com', 'https://naver.com' ) results ={} for website in websites: if not website.startswith('https://'): website = f"https://{website}" response = get(website) if response.status_code == 200: results[website] = "OK" else: results[website] = "FAILED" prin..

Programming/Python 웹 스크래퍼 만들기

Python Requests

4.7 Requests ​ Python Standard Library 사용해본다. Pyhon Standard Library 에 없는 것은 pypi 에서 찾을 수 있다. pypi - 다른 사람이 만든 project 나 module 을 모아둔 곳. https://pypi.org/ PyPI · The Python Package Index The Python Package Index (PyPI) is a repository of software for the Python programming language. pypi.org requests 를 검색해서 사용할 예정이다. reqeusts는 user의 python 코드에서 웹사이트로 request 보내는걸 할수 있게 해준다. ​ request 란 무엇인가? 예를 ..

Programming/Python 웹 스크래퍼 만들기

Python For Loops

4.5 For Loops ​ website 들을 리스트로 생성해 본다. 리스트에 있는 웹사이트가 동작중인지 내려갔는지 확인해 볼 것이다. websites = ( 'google.com', 'airbnb.com', 'facebook.com', 'naver.com' ) websites[0] 인덱스를 사용해서 각각 확인해보는 방법도 있지만, 시간이 오래 걸리고 효율이 떨어진다. 리스트가 얼마나 긴지 신경 안쓰면서 리스트의 각 아이템을 활용해서 자동으로 코드를 실행할 방법을 사용해야 한다. ​ 이걸 위해 for 반복문을 사용할 것 이다. websites 튜플 안에 있는 각각의 아이템을 사용해서 코드를 실행하려 한다. websites = ( 'google.com', 'airbnb.com', 'facebook.com..

Security Engineer
'Programming/Python 웹 스크래퍼 만들기' 카테고리의 글 목록 (5 Page)