Python请求结果缺少web pag的一部分

2024-09-28 17:04:28 发布

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

我尝试使用请求提交表单并下载结果网页。问题是,当我在浏览器上填写表单时,下载的页面缺少大部分页面。在

我想看一张座位图aa.com网站. 除了实际的座位图,我几乎什么都能拿到。在

from requests import session

def get_page():
    payload = {
        'airportLookupRequired': 'true',
        'currentCodeForm': 'originAirport',
        'currentCalForm': 'viewSeatsForm',
        'flightNumber': '1132',
        'departureMonth': '9',
        'departureDay': '22',
        'originAirport': 'dfw',
        'destinationAirport': 'lga',
        'cabin': 'coach',
        '_button_submit': 'GO'
    }

    with session() as c:
        c.post('https://www.aa.com/seatmap/viewSeatsAccess.do', payload)
        r = c.get('https://www.aa.com/seatmap/viewSeatsSubmit.do')
        print r.content.replace('/content/images', 'https://www.aa.com/content/images')      

get_page()

如果您有任何建议来解决这个问题或弄清楚它为什么不起作用,我们将不胜感激。在

编辑:我明白了,使用浏览器工具查找AJAX请求

^{pr2}$

点击即可:

// Provide a default path to dwr.engine
if (dwr == null) var dwr = {};
if (dwr.engine == null) dwr.engine = {};
if (DWREngine == null) var DWREngine = dwr.engine;

if (SeatMapAjaxUtils == null) var SeatMapAjaxUtils = {};
SeatMapAjaxUtils._path = '/dwr';
SeatMapAjaxUtils.formatAmount = function(p0, p1, callback) {
  dwr.engine._execute(SeatMapAjaxUtils._path, 'SeatMapAjaxUtils', 'formatAmount', p0, p1, callback);
}
SeatMapAjaxUtils.getExitRowSeatSelectionResponse = function(p0, callback) {
  dwr.engine._execute(SeatMapAjaxUtils._path, 'SeatMapAjaxUtils', 'getExitRowSeatSelectionResponse', p0, callback);
}

这似乎是生成我想要的信息的代码。我不知道怎么从那里开始。在


Tags: pathhttpscomgetifvarwwwcallback