Как дано в this вопросе, который я использовал ниже метод для нахождения окончательных перенаправлены URL вErlang Получить окончательный перенаправлен URL
URL="http://mail.google.com",
HTTPOpts = [{autoredirect, false}],
perform_request(URL) ->
case httpc:request(get, {URL, [{"User-Agent", "Mozilla"}]}, HTTPOpts, []) of
{ok, {{_, Code, _}, Headers, Body}} when Code == 200 ->
%%code_to_process_the_URL%%
{ok, {{_, Code, _}, Headers, _}} when Code < 310 , Code >= 300 ->
NewURL=proplists:get_value("location", Headers),
perform_request(NewURL)
end
Это прекрасно работает для другой URL, но он сталкивается проблемы с URL = https://mail.google.com
в качестве своего первого заголовка местоположения это location = /mail/
, который не является допустимым URL, и я получаю пустую страницу.
Я также сгенерировал вывод используя команду GET
, чтобы проверить это на терминале.
выход:
[email protected]:~$ GET -S -d -e http://mail.google.com
GET http://mail.google.com
301 Moved Permanently
Cache-Control: private, max-age=0
Connection: close
Date: Tue, 21 Feb 2017 11:56:14 GMT
Accept-Ranges: none
Location: /mail/
Server: GSE
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
Expires: Tue, 21 Feb 2017 11:56:14 GMT
Client-Date: Tue, 21 Feb 2017 11:55:30 GMT
Client-Peer: 216.58.197.69:80
Client-Response-Num: 1
Title: Moved Permanently
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
GET http://mail.google.com/mail/
302 Moved Temporarily
Cache-Control: private, max-age=0
Connection: close
Date: Tue, 21 Feb 2017 11:56:15 GMT
Accept-Ranges: none
Location: https://mail.google.com/mail/
Server: GSE
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
Expires: Tue, 21 Feb 2017 11:56:15 GMT
Client-Date: Tue, 21 Feb 2017 11:55:30 GMT
Client-Peer: 172.217.26.165:80
Client-Response-Num: 1
Title: Moved Temporarily
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
GET https://mail.google.com/mail/
302 Moved Temporarily
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: close
Date: Tue, 21 Feb 2017 11:56:21 GMT
Pragma: no-cache
Accept-Ranges: none
Location: https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&emr=1&osid=1
Server: GSE
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Alt-Svc: quic=":443"; ma=2592000; v="35,34"
Client-Date: Tue, 21 Feb 2017 11:55:36 GMT
Client-Peer: 216.58.197.69:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=US/O=Google Inc/CN=Google Internet
Authority G2
Client-SSL-Cert-Subject: /C=US/ST=California/L=Mountain View/O=Google Inc/CN=mail.google.com
Client-SSL-Cipher: ECDHE-ECDSA-AES128-GCM-SHA256
Client-SSL-Socket-Class: IO::Socket::SSL
Title: Moved Temporarily
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
GET https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&emr=1&osid=1
200 OK
Cache-Control: no-cache, no-store
Connection: close
Date: Tue, 21 Feb 2017 11:56:22 GMT
Pragma: no-cache
Server: GSE
Content-Type: text/html; charset=UTF-8
Expires: Mon, 01-Jan-1990 00:00:00 GMT
Alt-Svc: quic=":443"; ma=2592000; v="35,34"
Client-Date: Tue, 21 Feb 2017 11:55:38 GMT
Client-Peer: 172.217.26.173:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=US/O=Google Inc/CN=Google Internet Authority G2
Client-SSL-Cert-Subject: /C=US/ST=California/L=Mountain View/O=Google Inc/CN=accounts.google.com
Client-SSL-Cipher: ECDHE-RSA-AES128-SHA
Client-SSL-Socket-Class: IO::Socket::SSL
Client-Transfer-Encoding: chunked
Link: <https://www.google.com/gmail/>; rel="canonical"
Set-Cookie: GAPS=1:uiUyF1S0WckgUUlRhZmrUeuRVCgCiA:9vKBlzT8ecd7l7Ob;Path=/;Expires=Thu, 21-Feb-2019 11:56:22 GMT;Secure;HttpOnly;Priority=HIGH
Set-Cookie: GALX=mfArYRFLcco;Path=/;Secure
Strict-Transport-Security: max-age=10893354; includeSubDomains
Title: Gmail
X-Auto-Login:realm=com.google&args=service%3Dmail%26continue%3Dhttps%253A%252F%252Fmail.google.com%252Fmail%252F
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Meta-Charset: utf-8
X-Meta-Description: Gmail is email that's intuitive, efficient, and
useful. 15 GB of storage, less spam, and mobile access.
X-Meta-Google-Site-Verification: LrdTUW9psUAMbh4Ia074-BPEVmcpBxF6Gwf0MSgQXZs
X-Meta-Viewport: width=300, initial-scale=1
X-XSS-Protection: 1; mode=block
Как эта проблема может быть решена?
Какая команда командной строки? Ссылка? – 7stud