Skip to content

Commit

Permalink
代理使用不成功
Browse files Browse the repository at this point in the history
  • Loading branch information
JLUVicent committed Sep 16, 2021
1 parent df103cc commit 9438ad1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions 33_requests_代理.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

import requests
from requests.models import encode_multipart_formdata

url = 'http://www.baidu.com/s?'
data = {
'wd': 'ip'
}

proxy = {
'http://': '27.156.197.17:4235'
}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36'
}

response = requests.get(url=url, params=data, headers=headers, proxies=proxy)

content = response.text

with open('adaili.html', 'w', encoding='utf-8')as fp:
fp.write(content)

0 comments on commit 9438ad1

Please sign in to comment.