2016-10-11 89 views
-3

我想用python從HTML網站獲取片段。如何從外部HTML(網站)用python獲得代碼片段

例如,從url http://steven-universe.wikia.com/wiki/Steven_Universe_Wiki我想要將字符串「next Episode」中的文本作爲字符串。我怎麼才能得到它?

+3

1.學習Python的請求。 2.編碼。 3.如有特殊問題,請在此處詢問。 – timgeb

+0

http://stackoverflow.com/questions/2081586/web-scraping-with-python –

+0

你嘗試過什麼嗎?我建議使用'requests'模塊來訪問HTML,'BeautifulSoup'來解析它。 – mhawke

回答

0

的所有下載BeautifulSoup最新版本首先從herehere

from bs4 import BeautifulSoup 
import requests 

con = requests.get(url).content 
soup = BeautifulSoup(con) 
text = soup.find_all("a",href="/wiki/Gem_Harvest").text; 
print(link)