2
사용자가 필요하고 통과해야하는 웹 페이지에서 파일을 다운로드하고 싶지만 먼저 쿠키를 얻어야합니다. 내가하고 싶은 것은이 Python 스크립트에 정확하게 설명되어 있지만 Java를 사용하여 수행하려고합니다.자바로 쿠키가 포함 된 웹 페이지에 로그인하십시오.
나는 그것에 대해 읽었으며, 나는 httpclient 라이브러리를 발견했다. 내가 필요로하는 것은 모두 httpclient인가? 기계어 및 urllib2 자바에 대한 모든 해당 라이브러리?
미리 감사드립니다.
#!/usr/bin/python
import mechanize, urllib2
from urllib import urlopen, urlencode
user = 'username'
password = 'password'
output_file = 'name.pdf'
web = "https://..."
bills_page = "https://.../bills"
login_web = "https://.../login/"
file = "https://.../file_I_want"
br = mechanize.Browser()
br.open(web)
data = {
'user_username': user,
'user_password': password,
'idClientehidden': '',
'answer': ''
}
response1 = urllib2.Request(login_web, urlencode(data))
br.open(response1)
br.open(bills_page)
html_bills = br.response().read()
br.open(file)
pdf_bill = open(output_file, 'w')
pdf_bill.write(br.response().read())
pdf_bill.close()
쿠키 읽기에 관한 모든 것이 궁금하십니까? 또는 외부 웹에 로그인하여 파일을 다운로드 할 방법을 찾고 있습니까? –
외부 웹에 로그인하고 파일을 다운로드하는 방법. 제 질문은 내가 httpclient를 사용해야하거나 내 목표를 위해 뭔가를 더 잘 안다면입니다. –