我使用的代码:
@app.route('/api/redirect', methods=['GET'])
def redirect_link():
url = request.values.get('url')
return redirect(url)
问题在于,目标网站不会将%2C
解码为,
,而是解码为-
并提供404 Not Found
。
有什么方法吗?
带卷曲的标题:
curl -IL http://XXXXXX/api/redirect?url=http%3A%2F%2Fnachbarschaft.immobilienscout24.de%2Fadressen%2Fbayern%2Cmuenchen%2Chaidhausen%2Fdienstleistung%2Ffriseur-blatter-hauptverwaltung%2C66512592.html
HTTP/1.1 302 FOUND
Server: gunicorn/18.0
Date: Wed, 11 Dec 2013 12:58:26 GMT
Connection: keep-alive
Content-Type: text/html; charset=utf-8
Content-Length: 489
Location: http://nachbarschaft.immobilienscout24.de/adressen/bayern%2Cmuenchen%2Chaidhausen/dienstleistung/friseur-blatter-hauptverwaltung%2C66512592.html
HTTP/1.1 301 Moved Permanently
Date: Wed, 11 Dec 2013 12:58:27 GMT
Location: /adressen/bayern-muenchen-haidhausen/dienstleistung/friseur-blatter-hauptverwaltung-66512592.html
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: no-sniff
Cache-Control: max-age=604800, private, must-revalidate
Content-Type: text/html; charset=UTF-8
Set-Cookie: TS8a1db5=ea90e6be799ade80c5c84f3cca057558d12f3da1cca67c5a52a86172; Path=/
Transfer-Encoding: chunked
HTTP/1.1 404 Not Found
Date: Wed, 11 Dec 2013 12:58:27 GMT
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: no-sniff
Cache-Control: max-age=604800, private, must-revalidate
Content-Type: text/html; charset=UTF-8
Set-Cookie: TS8a1db5=61dcb89e16f8fe72a87d5e1f1faf7b0e82cbf7e476e5a3ff52a86172; Path=/
Transfer-Encoding: chunked