Proxy環境下でWebスクレイピング[request][BeautifulSoup]

7月 27, 2020

import urllib
from bs4 import BeautifulSoup
if __name__ == "__main__":
proxy = urllib.request.ProxyHandler({'http': 'http://xx.xx.xx.xx:8080'})
opener = urllib.request.build_opener(proxy)
url = "http://xx.xx"
urllib.request.install_opener(opener)
html = urllib.request.urlopen(url)
soup = BeautifulSoup(html, "html.parser")

Python

Posted by vastee