상세 컨텐츠

본문 제목

Python requests 모듈 사용하기

IT/파이썬

by SageIN 2021. 4. 27. 14:49

본문

반응형
import requests 
URL = 'https://search.shopping.naver.com/search/category' 
response = requests.get(URL)

# 기본적인 사용방법

 

url = 'https://search.shopping.naver.com/search/category'
    params = (
        ('catId', str(cateCode)),
        ('pagingIndex', '1'),
        ('pagingSize', '80'),
        ('productSet', 'total'),
        ('viewType', 'list'),
        ('sort', 'rel')
    )
 
 response = requests.get(
        url,
        params=params
    )

# 파라미터 넣기

 

 headers = {
        'authority': 'search.shopping.naver.com',
        'cache-control': 'max-age=0',
        'upgrade-insecure-requests': '1',
        'dnt': '1',
        'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36',
        'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
        'accept-encoding': 'gzip, deflate, br',
        'accept-language': 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6,da;q=0.5',
    }

params = (
        ('catId', '23145100'),
        ('pagingIndex', '1'),
        ('pagingSize', '80'),
        ('productSet', 'total'),
        ('viewType', 'list'),
        ('sort', 'rel')
    )

response = requests.get(
        url,
        headers=headers, params=params
    )

# 헤더값 넣기

반응형

관련글 더보기

댓글 영역