본문 바로가기

파이썬

beautiful soup user agent

from bs4 import BeautifulSoup

import requests

import urllib.request

import urllib.parse

 

url = "크롤링할 사이트 주소"

 

headers = {'User-Agent':'아래 링크에서 얻은 user agent 복붙'}

http://www.useragentstring.com/

 

r = requests.get(url, headers = headers)

soup = BeautifulSoup(r.text, 'html.parser')