使用python加载JavaScript后获取网站内容

时间:2016-06-27 15:13:28

标签: javascript python

我在获取内容方面遇到了问题:

with dryscrape.Session() as c:
    PASSWORD = '<PASS>'
    USERNAME = '<EMAIL>'
    URL = 'https://my.pingdom.com/'
    c.get(URL)
    soup = BeautifulSoup(c.get(URL).text, "lxml")
    csrf = soup.select_one("input[name=__csrf_magic]")["value"]
    login_data = {
        "email" : USERNAME,
        "password" : PASSWORD,
        "__csrf_magic" : csrf,}
r = c.post(URL, data=login_data, headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36'})
url = 'https://my.pingdom.com/newchecks/rums?ignoreActive=1'
r = c.get(url).text
print r

在浏览器中登录后,我在源代码中获得了加载时​​间的值,但是当我使用此scipt时,x-handlebars-template只有一个{{loadtime}}标记。 任何想法我怎么能得到它?这是服务器脚本,所以任何selenium类型的提示都不在这里。 :)

0 个答案:

没有答案