1
아시다시피 일부 captcha는 사용자 세션을 사용하여 생성되며, 어떻게 든이 이미지를 컴퓨터에 저장해야합니다.이 이미지는 우리의 응용 프로그램을 테스트하기위한 것이지만 선택 방법은 무엇입니까?ruby에서 쿠키를 사용하여 URL에서 이미지 가져 오기
HTTP에 예를 들어:: 내가 쿠키, 같은 코드를 얻을 :
http = Net::HTTP.new('***', 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
path = '****'
# GET request -> so the host can set his cookies
resp, data = http.get(path)
body_text = resp.body
#puts "Body = #{body_text}"
cookie = resp.response['set-cookie'].split('; ')[0]
@captcha_url = (/BotDetectCaptcha.ashx?get=image&c=***;t=(.*)" \/>/.match body_text)
# POST request -> logging in
puts "captcha_url = #{@captcha_url}"
data = 'BotDetectCaptcha.ashx?get=image&c=****&t=#{@captcha_url}'
headers = {
'Cookie' => cookie,
'Referer' => '****',
'Content-Type' => 'image-jpeg'
}
resp, data = http.post(path, data, headers)
그래서, 아마도, 내가 필요 이미지를 가지고 있지만! 내가 어떻게 구할 수 있니? 모든 google'd 기사는 내가 open-uri를 사용해야한다는 것을 말해 주지만, 세션을 사용해야 할 때는 어떻게해야합니까? 어쩌면 내가 루비의 http 클래스로 어떻게 든 할 수 있을까?
로드 된 페이지 또는 URL을 통해 이미지를 다운로드하려면 어떻게해야합니까?
체크 아웃은 세션을 설정하고 파일을 다운로드 할 수 있습니다 기계화 보석. – engineersmnky