小编Hop*_*nut的帖子

网络抓取谷歌航班价格

我正在尝试学习使用Python库BeautifulSoup,例如,我想在Google Flights上抓取某个航班的价格。因此,例如,我通过此链接连接到Google Flights,并且希望获得最便宜的航班价格。

因此,我将使用此类“ gws-flights-results__itinerary-price”(如图所示)在div中获取值。

图例

这是我写的简单代码:

from bs4 import BeautifulSoup
import urllib.request

url = 'https://www.google.com/flights?hl=it#flt=/m/07_pf./m/05qtj.2019-04-27;c:EUR;e:1;sd:1;t:f;tt:o'
page = urllib.request.urlopen(url)
soup = BeautifulSoup(page, 'html.parser')
div = soup.find('div', attrs={'class': 'gws-flights-results__itinerary-price'})
Run Code Online (Sandbox Code Playgroud)

但是结果div具有class NoneType

我也尝试

find_all('div') 
Run Code Online (Sandbox Code Playgroud)

但是在以这种方式找到的所有div中,没有我感兴趣的div。有人可以帮我吗?

python beautifulsoup web-scraping

5
推荐指数
1
解决办法
1494
查看次数

如何在Angular UI-Grid中获取列页脚数据?

例如,在本教程中,是否有任何方法可以在列页脚中获取数据?我想在其他地方展示总数. 在此输入图像描述 提前致谢.

javascript angularjs angularjs-directive angularjs-scope angular-ui-grid

1
推荐指数
1
解决办法
2035
查看次数