Python CURL输出与原始html不同 [英] Python CURL output different from original html

查看:58
本文介绍了Python CURL输出与原始html不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Spotify网站获取HTML正文.但是,在将其输出到文件后,由于某种原因,结果与原始HTML有所不同(这是一个完全不同的站点).

I am trying to get HTML body from Spotify web. But after I output it to the file the result is for some reason different from the original HTML (it's a completely different site).

curl https://open.spotify.com/artist/4npEfmQ6YuiwW1GpUmaq3F > test.html

最终,我将使用python进行操作,因此,如果有人知道如何绕过此页面重定向,请提供帮助.

Eventually, I will do in python so if anyone knows how to get around this page redirect, please help.

推荐答案

Spotify识别出您使用了不受支持的浏览器",Curl不是浏览器,所以不要以为它会像您将需要伪造"通过添加正确的标题使用真实的浏览器,像这样:

Spotify recognize that you use unsupported "browser", Curl is not a browser so don't think it will behave like one you will need to "fake" that you use a real browser by adding the right headers, something like:

curl 'https://open.spotify.com/artist/4npEfmQ6YuiwW1GpUmaq3F' \
-X 'GET' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15'

这篇关于Python CURL输出与原始html不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆