0

我正在尝试使用请求来提交表单并下载生成的网页。问题是下载的页面缺少我在浏览器上填写表单时看到的大部分页面。

我正在尝试在 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 请求,我明白了

Resource interpreted as Script but transferred with MIME type text/plain: "https://www.aa.com/dwr/interface/SeatMapAjaxUtils.js". viewSeatsSubmit.do:52

单击它会导致:

// 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);
}

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

4

0 回答 0