Python-从 asp.net AJAX 应用程序获取数据
使用Python,我尝试读取 http://utahcritseries.com/RawResults.aspx 上的值。 我可以很好地阅读该页面,但很难更改年份组合框的值以查看其他年份的数据。 如何读取除默认 2002 年以外的年份的数据?
一旦年份组合框发生更改,该页面似乎正在执行 HTTP Post。 该控件的名称是 ct100$ContentPlaceHolder1$ddlSeries。 我尝试使用 urllib.urlencode(postdata) 为该控件设置一个值,但我一定做错了什么——页面上的数据没有改变。 这可以用 Python 完成吗?
如果可能的话,我宁愿不使用 Selenium。
我一直在使用这样的代码(来自 stackoverflow 用户 dbr),
import urllib
postdata = {'ctl00$ContentPlaceHolder1$ddlSeries': 9}
src = urllib.urlopen(
"http://utahcritseries.com/RawResults.aspx",
data = urllib.urlencode(postdata)
).read()
print src
但似乎提取了相同的 2002 年数据。 我尝试过使用 firebug 来检查标头,并且看到很多无关且看起来随机的数据来回发送 - 我是否也需要将这些值发布回服务器?
Using Python, I'm trying to read the values on http://utahcritseries.com/RawResults.aspx. I can read the page just fine, but am having difficulty changing the value of the year combo box, to view data from other years. How can I read the data for years other than the default of 2002?
The page appears to be doing an HTTP Post once the year combo box has changed. The name of the control is ct100$ContentPlaceHolder1$ddlSeries. I try setting a value for this control using urllib.urlencode(postdata), but I must be doing something wrong-the data on the page is not changing. Can this be done in Python?
I'd prefer not to use Selenium, if at all possible.
I've been using code like this(from stackoverflow user dbr)
import urllib
postdata = {'ctl00$ContentPlaceHolder1$ddlSeries': 9}
src = urllib.urlopen(
"http://utahcritseries.com/RawResults.aspx",
data = urllib.urlencode(postdata)
).read()
print src
But seems to be pulling up the same 2002 data. I've tried using firebug to inspect the headers and I see a lot of extraneous and random-looking data being sent back and forth-do I need to post these values back to the server also?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用优秀的 mechanize 库:
Mechanize 可在 PyPI 上使用:
easy_install mechanize
Use the excellent mechanize library:
Mechanize is available on PyPI:
easy_install mechanize