如何将网页抓取的数据用于网页

时间:2019-03-17 11:51:26

标签: database web screen-scraping

我看到了代码,我想尝试/将其实现到网页上以放置一些数据。(您可以在下面的图片中看到它)

[在此处输入图片描述] [1]

import requests
from bs4 import BeautifulSoup
import time

def get_count():
    url = "https://data-live.flightradar24.com/zones/fcgi/feed.js?bounds=59.09,52.64,-58.77,-47.71&faa=1&mlat=1&flarm=1&adsb=1&gnd=1&air=1&vehicles=1&estimated=1&maxage=7200&gliders=1&stats=1"
    # Request with fake header, otherwise you will get an 403 HTTP error
    r = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'})

    # Parse the JSON
    data = r.json()
    counter = 0

    # Iterate over the elements to get the number of total flights
    for element in data["stats"]["total"]:
        counter += data["stats"]["total"][element]

    return counter

while True:
    print(get_count())
    time.sleep(8)

我刚刚开始学习用精美的汤刮网。

0 个答案:

没有答案