2016-10-11 53 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)