我在使用BeautifulSoup爬取网页的时候发现结果为空 有人知道什么原因吗
我爬下来的html和检索网页的html不一样 有人知道原因吗
import requests
from bs4 import BeautifulSoup
url = "http://www.yuexingjp.com/flight/showfarefirst.aspx?from=CTU&to=PEK&__today__=20220709&FlightType=1&fc=%E6%88%90%E9%83%BD&tc=%E5%8C%97%E4%BA%AC&date=2022-07-22"
webpage_source = requests.get(url).text
content = BeautifulSoup(webpage_source, 'html5lib')
print(content.find_all(class_ = 'flight_airline'))
emmmm,你打印webpage_source 看下有没有请求url返回网页
你好,爬取的页面中不存在 flight_airline元素
我试了一下,你这个获取到的页面里就没有这个class,你把class换成riqi就有了,不是代码问题,时内容的问题
这篇文章讲的很详细,请看:Beautifulsoup爬取网页标题