截取 http://beans.itcarlow.ie/prices.html 的網頁資訊


程式碼:

 

import urllib.request

 

page=urllib.request.urlopen("http://beans.itcarlow.ie/prices.html")
text=page.read().decode("utf8")

 

where=text.find(">$")

 

start_of_price=where+1

 

end_of_price=start_of_price+4

 

price=text[start_of_price:end_of_price]

 

print("今天咖啡豆的價錢是"+price+"元")


果:

>>> ============= RESTART ==============
>>>
今天咖啡豆的價錢是$5.5元---->(這個數字不一定會一樣)
>>>


原紗央莉08.jpg  

arrow
arrow
    全站熱搜

    silentpower 發表在 痞客邦 留言(0) 人氣()