scraping dynamic updates of temperature sensor data from a website

后端 未结 3 354
天涯浪人
天涯浪人 2021-01-17 06:24

I wrote following python code:

from bs4 import BeautifulSoup
import urllib2

url= \'http://www.example.com\'
page = urllib2.urlopen(url)
soup = BeautifulSoup         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 06:58

    You're missing a tiny bit of code:

    from bs4 import BeautifulSoup
    import urllib2
    
    url= 'http://www.example.com'
    page = urllib2.urlopen(url)
    soup = BeautifulSoup(page.read(), 'html.parser')
    freq = soup.find('div', attrs={'id':'frequenz'})
    print freq.string  # Added .string
    

提交回复
热议问题