请求和urllib2从XBRL页获取错误。'您正在运行的浏览器模式与此应用程序的不兼容

2024-05-15 00:51:49 发布

您现在位置:Python中文网/ 问答频道 /正文

不知道为什么我不能从这个链接获取页面。我想做的就是把它拿到美丽之群。你知道吗

import requests,urllib2

link='https://www.sec.gov/ix?doc=/Archives/edgar/data/1373715/000137371518000157/now-2018630x10q.htm'

r = requests.get(link)

r2=urllib2.urlopen(link)
html=r2.read()

还尝试用以下内容伪造浏览器:

headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}

r = requests.get(link, headers=headers)

文本相同。。。不是我想要的那一页。你知道吗

得到这样的标题

var note = 'The browser mode you are running is not compatible with this application.';

            browserName ='Microsoft Internet Explorer';

            note +='You are currently running '+browserName+' '+((ie7>0)?7:8)+'.0.';       

                var userAgent = window.navigator.userAgent.toLowerCase();           

                if(userAgent.indexOf('ipad') != -1 || userAgent.indexOf('iphone') != -1 || userAgent.indexOf('apple') != -1){               

                    note += ' Please use a more current version of '+browserName+' in order to use the application.';

                }else if(userAgent.indexOf('android') != -1){               

                    note += ' Please use a more current version of Google Chrome or Mozilla Firefox in order to use the application.';

                }else{              

                    note += ' Please use a more current version of Microsoft Internet Explorer, Google Chrome or Mozilla Firefox in order to use the application.';

                }

我可以很好地完成这一页: https://www.sec.gov/Archives/edgar/data/1373715/000137371518000153/erq2fy18-document.htm

不是XBRL文档。我认为这与XBRL有关,服务器希望我的浏览器与数据交互?你知道吗


Tags: mozillaapplicationuseversionmorelinkcurrentchrome
1条回答
网友
1楼 · 发布于 2024-05-15 00:51:49

页面的这部分似乎是由js呈现的。通常动态内容最可靠的选项是selenium,但在这种情况下,您可以避免使用它并使用requests。你知道吗

很明显,页面使用了这个文档的内容/Archives/edgar/data/1373715/000137371518000157/now-2018630x10q.htm。您可以绕过该页直接请求文档。你知道吗

import requests

url = "https://www.sec.gov/Archives/edgar/data/1373715/000137371518000157/now-2018630x10q.htm"
r = requests.get(url)
html = r.text

print(html)

相关问题 更多 >

    热门问题