티스토리 뷰

공부

[Python] requests UserAgent

승가비 2020. 4. 3. 00:03
728x90
import requests 

url = 'https://httpbin.org/user-agent'
user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'
headers = {'User-Agent': user_agent}

response = requests.get(url,headers=headers)
html = response.content
print(response.content)

https://www.scrapehero.com/how-to-fake-and-rotate-user-agents-using-python-3/

 

How to Fake and Rotate User Agents Using Python 3

When scraping many pages from a website, using the same user-agent consistently leads to the detection of a scraper. A way to bypass that detection is by faking your user agent and changing it with every request you make to a website. In this tutorial, we

www.scrapehero.com

 

 

728x90
댓글