Javascript错误:登录网站的Python例程

时间:2015-05-07 14:01:55

标签: javascript python

我一直试图进入一个网站并使用python获取一些数据。但是当我运行脚本时,我遇到了一个错误。在这里,我想尝试登录网站并打印整个网站文本。脚本和错误如下:

脚本:

import requests

with requests.session() as s:
    proxy_url = "http://{0}:{1}@proxy.blah.blah.com:8099".format('user_id', 'Password')
    s.proxies = {'http': proxy_url, 'https': proxy_url}

    user_id_url = "https://example.ex.com/my.policy"
    Headers = {'Host': 'example.ex.com', 'Connection': 'keep-alive','Cache-Control': 'max-age=0', 'Accept-Language': 'en-US,en;q=0.8', 'Accept-Encoding': 'gzip, deflate, sdch','Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Cookie': '_ga=GA1.2.1822238803.1429212674; LastMRH_Session=0a0d8c67; MRHSession=ded054e0afe1bb151c3d35cb0a0d8c67; TIN=273000', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36'}
    data = data = {'username': 'website_uid', 'password': 'website_password'}
    r= s.post(user_id_url, data = data, headers = Headers)
    print r.status_code
    print r.text

错误:

<script language="javascript">
setDefaultLang();
</script><noscript>
<div id="noscript_warning_red">JavaScript is not enabled. Please enable JavaScript in your browser or contact your system administrator for assistance.</div>
<div id="noscript_warning_newsession">To open a new session, please  <A href="/">click here.</A></div>
</noscript>

PS:我能够打印页面的html文本,但我无法正确登录,因此显示错误输出。

我的浏览器启用了Javascript,即使在发布此问题时我也会仔细检查

非常感谢任何帮助

0 个答案:

没有答案