有人能告诉我如何用python读取那个文件吗?

2024-06-23 19:26:13 发布

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

这是在浏览LinkedIn页面后在Python中使用scrapy splash的结果。这是它的开始

b'<html><head></head><body>\x1f\xef\xbf\xbd\x08\x03\xef\xbf\xbd\xef\xbf\xbdko+I\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\x0f1\x1cT]]\xef\xbf[...]

我不知道怎么读这个?谢谢


Tags: htmlbody页面headlinkedinscrapyxbdx03
1条回答
网友
1楼 · 发布于 2024-06-23 19:26:13

所以看起来像是我评论的那句话。。。不知道为什么

lua_script = """
function main(splash)
    splash.private_mode_enabled = false
    assert(splash:go{
        splash.args.url,
        headers=splash.args.headers,
    })
    assert(splash:wait(5))
    return {html=splash:html()}
end
"""

yield SplashRequest(url=self.url, callback=self.parse,
                    endpoint='render.html',
                    args={'lua_source': lua_script,
                          'wait': 5,
                          'private_mode_enabled': 'false',
                          },
                    headers={
                        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
                        'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
                        'accept-language': 'en-US,en;q=0.9,fr;q=0.8',
                        #'accept-encoding': 'gzip, deflate, br',  # if used then file looks like shit
                        'referer': 'https://www.google.com/',
                        'upgrade-insecure-requests': 1,
                    },
                    )

相关问题 更多 >

    热门问题