我对网络刮擦很陌生。我想从以下方面收集数据:
我可以看到很多TOCs在那里。我想用这个量刮一下"Income before income taxes"这个词。请分享一些想法,并在这上面放点灯。
base_url="https://www.sec.gov/Archives/edgar/data/814453/000119312518067603/d494599d10k.htm#tx494599_11"
from lxml.etree import fromstring, HTMLParser
import requests
r = requests.get(base_url).content
xml = fromstring(r, HTMLParser())
print(xml.xpath("//span[@class='Text Intro Justify' and contains(text(),'impact')]//text()"))发布于 2018-09-21 04:51:59
这将为您提供表中的所有内容,您只需找到您想要的具体内容:
import urllib2
from bs4 import BeautifulSoup
quote_page = 'https://www.sec.gov/Archives/edgar/data/814453/000119312518067603/d494599d10k.htm#tx494599_11'
page = urllib2.urlopen(quote_page)
soup = BeautifulSoup(page, 'html.parser')
header = soup.find("b", text="2017 (1)")
table = header.find_parent("table")
for row in table.find_all("tr")[2:]:
print([cell.get_text(strip=True) for cell in row.find_all("td")])https://stackoverflow.com/questions/52436525
复制相似问题