html - How to get text following a table/span with BeautifulSoup and Python? -


i need text 2,585 shown in screenshot below. new coding, have far:

import urllib2 bs4 import beautifulsoup  url= 'inserturl' r = requests.get(url) data = r.text soup = beautifulsoup(data, 'html.parser') span = soup.find('span', id='d21475972e793-wk-fact -8d34b98c76ef518c788a2177e5b18db0') print (span.text) 

any info helpful!! thanks.

website html

3 things, using requests not urllib2. selecting xml namespaces need use xml parser. element want not span ix:nonfraction. here working example using web-page (you need point @ page , use commented line).

# using requests no need urllib2. import requests bs4 import beautifulsoup  # using page example. url= 'https://www.sec.gov/archives/edgar/data/27904/000002790417000004/0000027904-17-000004.txt' r = requests.get(url) data = r.text # use xml parser. soup = beautifulsoup(data, 'xml') ix = soup.find('ix:nonfraction', id="fact-7365d69e1478b0a952b8159a2e39b9d8-wk-fact-7365d69e1478b0a952b8159a2e39b9d8") # original code page. # ix = soup.find('ix:nonfraction',  id='d21475972e793-wk-fact-8d34b98c76ef518c788a2177e5b18db0') print (ix.text) 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -