爬取春秋航空航班信息

一、使用fiddler爬取小程序春秋航空航班信息

使用Fiddler爬取春秋航空微信小程序(手机上由于网络问题,无法进入,使用电脑版)
搜索航班信息
搜索记录
使用Fiddler查找url(没有得到有效url)
继续查找,发现航班信息列表(打开查看,列表为空)
重新搜索,再次查找(发现航班信息,但url无效,不能正常使用)
微信小程序好像被加密了,无法正常爬取

二、使用网页版春秋航空,爬取网页信息

进入网页查找url(发现一个貌似url的内容,打开发现无效)
继续查找url(找到航班信息网页信息,查找到url)
  1. 相关代码
python 复制代码
import requests
from bs4 import BeautifulSoup

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36',
}
url = "https://flights.ch.com/SIA-CAN.html?Departure=%E8%A5%BF%E5%AE%89&Arrival=%E5%B9%BF%E5%B7%9E&FDate=2023-11-23&DepartCityCode=&ArriveCityCode=&IsSearchDepAirport=false&IsSearchArrAirport=false&isOnlyZf=false&ANum=1&CNum=0&INum=0&IfRet=false&SType=1&MType=0&IsNew=1"

response = requests.get(url=url,headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
flight_type = soup.find('div', class_='cell area cell-drop cell-flight-type')
flight_info = soup.find('div', class_='cell ori')
flight_outfo = soup.find('div', class_='cell des')
flight_line = soup.find('div', class_='go-date cell date')

type_list = flight_type.find('input',class_='val').get('value')
departure_city = flight_info.find('input', class_='val city scity').get('value')
destination_city = flight_outfo.find('input', class_='val city').get('value')
trip_date = flight_line.find('input', class_='val date').get('value')

print(f"行程类型:{type_list} 出发地:{departure_city} 目的地:{destination_city} 行程日期:{trip_date}")

爬取结果

相关推荐
汤姆yu6 分钟前
基于python的外卖配送及数据分析系统
开发语言·python·外卖分析
如何原谅奋力过但无声28 分钟前
TensorFlow 1.x常用函数总结(持续更新)
人工智能·python·tensorflow
翔云 OCR API30 分钟前
人脸识别API开发者对接代码示例
开发语言·人工智能·python·计算机视觉·ocr
AndrewHZ2 小时前
【图像处理基石】如何在图像中提取出基本形状,比如圆形,椭圆,方形等等?
图像处理·python·算法·计算机视觉·cv·形状提取
温轻舟2 小时前
Python自动办公工具05-Word表中相同内容的单元格自动合并
开发语言·python·word·自动化办公·温轻舟
习习.y3 小时前
python笔记梳理以及一些题目整理
开发语言·笔记·python
撸码猿4 小时前
《Python AI入门》第10章 拥抱AIGC——OpenAI API调用与Prompt工程实战
人工智能·python·aigc
qq_386218994 小时前
Gemini生成的自动搜索和下载论文的python脚本
开发语言·python
vx_vxbs664 小时前
【SSM电影网站】(免费领源码+演示录像)|可做计算机毕设Java、Python、PHP、小程序APP、C#、爬虫大数据、单片机、文案
java·spring boot·python·mysql·小程序·php·idea
烤汉堡6 小时前
Python入门到实战:post请求+cookie+代理
爬虫·python