BS4

import bs4
import requests

p = {'http': 'http://127.0.0.1:1080', 'https': 'http://127.0.0.1:1080'}

r = requests.get(url="https://www.baidu.com", proxies=p)
print(r.status_code)
r.encoding = r.apparent_encoding
soup = bs4.BeautifulSoup(r.text, 'lxml')
with open("./aaabb.html", 'w', encoding='utf-8') as f:
    f.write(soup.prettify())

 

posted @ 2020-06-27 11:19  静静别跑  阅读(40)  评论(0编辑  收藏  举报