0
일반 배경 :어떻게 requests.Session() 객체의 프록시를 변경합니까?
나는 프록시의 목록을 가지고 있고, 나는 PDF URL의 목록을 가지고있다. 나는이 PDF 파일을 다운로드 중이다.
다운로드마다 프록시를 전환 할 수 있기를 원합니다.
몇 가지 답변에서 다음을 보았지만 한 번에 사용 된 모든 프록시입니까? 아니면 프록시의 딕트에서 임의로 선택합니까? 사용할 프록시를 어떻게 선택합니까? 여기
proxies = {
'https': 'http://username:[email protected]:port',
'https': 'http://[email protected]:port',
'https': 'http://[email protected]:port',
'https': 'http://[email protected]:port',
'https': 'http://[email protected]:port',
'https': 'http://[email protected]:port'
}
는 현재 코드의 예제 샘플입니다 내가 가진
내 코드 :
s = requests.Session()
data = {"Username":"usr", "Password":"psw"}
url = "https://someSite.com"
#Logging into the site
s.post(url, data=data) #add proxies=proxies here?
for download_url in PDFLinks:
temp = s.get(download_url).content
내가 사용할 수있는 프록시 서버의 목록을 가지고
https_proxy_list = "https://IP:port", "https://IP:port", "https://IP:port"
요청의 프록시를 변경하려면 어떻게해야합니까? Session() 객체? POST 및 GET 모두
프록시를 변경하면 사이트에 다시 로그인 할 필요가 없습니다.