python - 使用 Mechanize 和 python 的站点抓取下拉列表

标签 python beautifulsoup mechanize

我正在尝试使用 mechanize 和 python 从网站获取可用的航类数据,http://www.jet4you.com但下拉列表控件对可用项目显示“无”。有没有办法得到 <options>使用 mechanize、urllib 或 beautifulsoup?

当我使用 fiddler 提交表单时,我看到了下拉列表的值,但我无法使用 mechanize 选择它们。

br = mechanize.Browser()
br.possible_items("AvailabilityCompactSearchInputViewType$DropDownListMarketOrigin1")
["none"]

最佳答案

为 javascript 放弃 Mechanize。使用支持 javascript 的浏览器模拟器,例如 selenium。我也为此尝试过 Mechanize ,但它只是失败了。

关于python - 使用 Mechanize 和 python 的站点抓取下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8636764/

相关文章:

python - 如何使用 BeautifulSoup (python) 防止关闭错误 HTML 中的标签?

javascript - python的 Mechanize 和形式: javascript string returned

ruby - 是否可以将 Mechanize::File 转换为 Mechanize::Page

python - 在 python 中平均多个掩码 numpy 数组

javascript - 使用 BeautifulSoup 解析 HTML 标签时显示为空,但在浏览器中打开时有内容

python - Dask "Column Assignment Doesn' t 支持时间戳”

python - 如何使用 Beautiful Soup BS4 抓取雅虎财经上的多个页面

python mechanize 点击按钮

Python Pandas Dataframe - 每两周计算值的总和

python - 如何解决 Django 中的 "TypeError at/post/new/"