Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何获取以前的';分区';(';div';略高于当前的';div';)_Python_Web Scraping_Beautifulsoup - Fatal编程技术网

Python 如何获取以前的';分区';(';div';略高于当前的';div';)

Python 如何获取以前的';分区';(';div';略高于当前的';div';),python,web-scraping,beautifulsoup,Python,Web Scraping,Beautifulsoup,我的HTML如下所示 <div style="TEXT-ALIGN: left; TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt"> <div style="TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt" align="center"><font style="DISPLAY: in

我的HTML如下所示

<div style="TEXT-ALIGN: left; TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt">
<div style="TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt" align="center"><font style="DISPLAY: inline; FONT-FAMILY: Times New Roman; FONT-SIZE: 10pt; FONT-WEIGHT: bold"><font style="BACKGROUND-COLOR: #ffffff; DISPLAY: inline">PART II</font></font></div>

<div style="TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt" align="justify">&nbsp;</div>

<div style="TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt" align="left"><font style="DISPLAY: inline; FONT-FAMILY: Times New Roman; FONT-SIZE: 10pt; FONT-WEIGHT: bold"><font style="BACKGROUND-COLOR: #ffffff; DISPLAY: inline">ITEM 5. MARKET FOR REGISTRANT’S COMMON EQUITY AND RELATED STOCKHOLDER MATTERS.</font></font></div>

<div style="TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt" align="justify">&nbsp;</div>

<div style="TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt" align="left"><font style="DISPLAY: inline; FONT-FAMILY: Times New Roman; FONT-SIZE: 10pt"><font style="BACKGROUND-COLOR: #ffffff; DISPLAY: inline">Our common stock is quoted on the OTCBB under the symbol UOIP. The reported high and low closing prices for the common stock as reported on the OTCBB are shown below for the periods indicated. The quotations reflect inter-dealer prices, without retail mark-up, markdown or commission, and may not represent actual transactions.</font></font></div>

<div style="TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt" align="left">&nbsp;</div>

<div align="left">
<table cellpadding="0" cellspacing="0" width="100%" style="FONT-FAMILY: times new roman; FONT-SIZE: 10pt; FONT-SIZE: 10pt; FONT-FAMILY: times new roman">
<tbody><tr>
<td valign="bottom" style="PADDING-BOTTOM: 2px"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">&nbsp; </font></td>
<td valign="bottom" style="PADDING-BOTTOM: 2px"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt; FONT-WEIGHT: bold">&nbsp;</font></td>
<td colspan="2" valign="bottom" style="BORDER-BOTTOM: black 2px solid">
<div style="TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt" align="center"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 8pt; FONT-WEIGHT: bold">High</font></div>
</td>
<td nowrap="" valign="bottom" style="TEXT-ALIGN: left; PADDING-BOTTOM: 2px"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 8pt; FONT-WEIGHT: bold">&nbsp;</font></td>
<td valign="bottom" style="PADDING-BOTTOM: 2px"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 8pt; FONT-WEIGHT: bold">&nbsp;</font></td>
<td colspan="2" valign="bottom" style="BORDER-BOTTOM: black 2px solid">
<div style="TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt" align="center"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 8pt; FONT-WEIGHT: bold">Low</font></div>
</td>
<td nowrap="" valign="bottom" style="TEXT-ALIGN: left; PADDING-BOTTOM: 2px"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt; FONT-WEIGHT: bold">&nbsp;</font></td>
</tr><tr>
<td align="left" valign="bottom">
<div style="TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt" align="left"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt; FONT-WEIGHT: bold">Nine months ended June 30, 2014</font></div>
</td>
<td align="left" valign="bottom"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">&nbsp;</font></td>
<td align="left" colspan="2" valign="bottom"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">&nbsp;</font></td>
<td nowrap="" valign="bottom" style="TEXT-ALIGN: left"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">&nbsp;</font></td>
<td align="left" valign="bottom"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">&nbsp;</font></td>
<td align="left" colspan="2" valign="bottom"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">&nbsp;</font></td>
<td nowrap="" valign="bottom" style="TEXT-ALIGN: left"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">&nbsp;</font></td>
</tr><tr bgcolor="#cceeff">
<td align="left" valign="bottom" width="76%">
<div style="TEXT-INDENT: 0pt; DISPLAY: block; MARGIN-LEFT: 0pt; MARGIN-RIGHT: 0pt" align="left"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">First quarter ended December 31, 2013</font></div>
</td>
<td align="right" valign="bottom" width="1%"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">&nbsp;</font></td>
<td valign="bottom" width="1%" style="TEXT-ALIGN: left"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">$</font></td>
<td valign="bottom" width="9%" style="TEXT-ALIGN: right"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">12.4000</font></td>
<td nowrap="" valign="bottom" width="1%" style="TEXT-ALIGN: left"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">&nbsp;</font></td>
<td align="right" valign="bottom" width="1%"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">&nbsp;</font></td>
<td valign="bottom" width="1%" style="TEXT-ALIGN: left"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">$</font></td>
<td valign="bottom" width="9%" style="TEXT-ALIGN: right"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">3.6400</font></td>
<td nowrap="" valign="bottom" width="1%" style="TEXT-ALIGN: left"><font style="DISPLAY: inline; FONT-FAMILY: times new roman; FONT-SIZE: 10pt">&nbsp;</font></td>
</tr>

第二部分
项目5。注册人普通股市场及相关股东事宜。
我们的普通股在OTCBB上以UOIP符号报价。OTCBB上报告的普通股收盘价的高低如下所示。报价反映经销商间的价格,没有零售加价、降价或佣金,可能不代表实际交易。
高
低
截至2014年6月30日的九个月
截至2013年12月31日的第一季度
$
12.4000
$
3.6400
我使用
find_all('table')
找到了该表。如何获取任何以前的
div
s,其中包含文本(或任何数据/非空)。(位于具有表格的div之前的div)

我尝试了
find_previous('div')
,但没有成功。请帮忙

soup = bs4.BeautifulSoup(html, 'html.parser')
table = soup.find('table')
prev_div = table.find_previous('div').find_previous('div').find_previous('div').text

输出:

'Our common stock is quoted on the OTCBB under the symbol UOIP. The reported high and low closing prices for the common stock as reported on the OTCBB are shown below for the periods indicated. The quotations reflect inter-dealer prices, without retail mark-up, markdown or commission, and may not represent actual transactions.'

我的猜测是,如果使用的是
find_all()
,则需要指定table@chitown88,只有一个表,然后不要使用
find_all()
,只使用
find()
。“全部查找”将返回给您一个列表。即使这是一个1的列表element@chitown88,好的,明白了。但是如何将上一个
div
fid到表中的那一个?您想要什么?
?谢谢,我找到了表的上一个div,它给出了与表相同的div。是的,多个div很棘手。我以前很少使用find_,因此可能有一种更优雅的方法,但它可以完成任务
'Our common stock is quoted on the OTCBB under the symbol UOIP. The reported high and low closing prices for the common stock as reported on the OTCBB are shown below for the periods indicated. The quotations reflect inter-dealer prices, without retail mark-up, markdown or commission, and may not represent actual transactions.'