2016-07-30 50 views
-1

嗨现在用美丽的汤欧元解压到我们价值,这是我走到这一步:我如何提取美丽的值?

import requests 
from bs4 import BeautifulSoup 

def Euro_spider(): 
    url = 'http://fx-rate.net/USD/' 
    source_code = requests.get(url) 
    plain_text = source_code.text 
    soup = BeautifulSoup(plain_text, "html.parser") 

什么,我要做什么?

+0

我很抱歉地说,你会趴下投票赞成这样的问题。一般而言,您需要在发布问题前展示您尝试的内容。考虑谷歌搜索美丽的汤教程。 – Leon

+0

我尝试了很多东西。但是,现在我看到,我以前把.get_text()。 Alecxe感谢他。 – solidsnake

回答

0

现在你需要找到包含速度正确的元素:

<a href="/USD/EUR/" class="1rate" title="Dollar to Euro">0.895</a> 

你可以找到它,例如,通过title

usd_to_euro = soup.find(title="Dollar to Euro").get_text() 
print(usd_to_euro) # prints 0.895