2014-02-21 113 views
0

我正在使用python。我正在學習beautifulsoup &我正在解析一個鏈接。使用beautifulsoup獲取電子郵件ID

我的網址:

http://www.dtemaharashtra.gov.in/approvedinstitues/StaticPages/frmInstituteSummary.aspx?InstituteCode=1002 

我想從URL解析電子郵件ID。
我該怎麼做?

+0

什麼電子郵件ID? [email protected]? –

+0

是的,我想獲取該電子郵件ID – sam

+0

你是垃圾郵件發送者嗎? – tripleee

回答

1
import urllib2 
from bs4 import BeautifulSoup 

html = urllib2.urlopen('http://www.dtemaharashtra.gov.in/approvedinstitues/StaticPages/frmInstituteSummary.aspx?InstituteCode=1002').read() 
soup = BeautifulSoup(html) 
print soup.find(id='ctl00_rightContainer_ContentBox1_lblEMailAddress').text 
+0

感謝它的工作 – sam

1
import requests 
from bs4 import BeautifulSoup 
r = requests.get("http://www.dtemaharashtra.gov.in/approvedinstitues/StaticPages/frmInstituteSummary.aspx?InstituteCode=1002") 
soup = BeautifulSoup(r.text) 
soup.find("span", {"id":"ctl00_rightContainer_ContentBox1_lblEMailAddress"}).text 
相關問題