How to scrape real time streaming data with Python?

后端 未结 3 619
故里飘歌
故里飘歌 2021-01-31 12:59

I was trying to scrape the number of flights for this webpage https://www.flightradar24.com/56.16,-49.51

The number is highlighted in the picture below:

The num

3条回答
  •  后悔当初
    2021-01-31 13:39

    You can use selenium to crawl a webpage with dynamic content added by javascript.

    from bs4 import BeautifulSoup
    from selenium import webdriver
    
    browser = webdriver.PhantomJS()
    browser.get('https://www.flightradar24.com/56.16,-49.51/3')
    
    soup = BeautifulSoup(browser.page_source, "html.parser")
    result = soup.find_all("span", {"id": "menuPlanesValue"})
    
    for item in result:
        print(item.text)
    
    browser.quit()
    

提交回复
热议问题