У меня есть HTML-документ, который я взял через красивый суп.Выдержка HTML находится в нижней части этого вопроса.Я пользуюсь прекрасным супом и селеном.
Мне сказали, что мне разрешено извлекать столько данных в час, а когда я получаю эту страницу, то немного подожду (хороший час).
Вот как я пытаюсь извлечь данные:
def get_page_data(self):
opts = Options()
opts.headless = True
assert opts.headless # Operating in headless mode
browser_detail = Firefox(options=opts)
url = self.base_url.format(str(self.tracking_id))
print(url)
browser_detail.get(url)
self.page_data = bs4(browser_detail.page_source, 'html.parser')
Error_Check = 1 if len(self.page_data.findAll(text='Error Report Number')) > 0 else 0
Error_Check = 2 if len(self.page_data.findAll(text='exceeded the maximum number of sessions per hour allowed')) > 0 else Error_Check
print(self.page_data.findAll(text='waiting an hour and trying your query again')). ##<<--- The Problem is this line.
print(self.page_data)
return Error_Check
Проблема в этой строке:
print(self.page_data.findAll(text='waiting an hour and trying your query again')). ##<<--- The Problem is this line.
Код не может найти строку встраница.Что мне не хватает?Спасибо
<html><head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<link href="/CMPL/styles/ogm_style.css;jsessionid=rw9pc8-bncrIy_4KSZmJ8BxN2Z2hnKVwcr79Vho4-99gxTPrxNbo!-68716939" rel="stylesheet" type="text/css"/>
<body>
<!-- Content Area -->
<table style="width:100%; margin:auto;">
<tbody><tr valign="top">
<td class="ContentArea" style="width:100%;">
<span id="messageArea">
<!-- /tiles/messages.jsp BEGIN -->
<ul>
</ul><b>
</b><table style="width:100%; margin:auto; white-space: pre-wrap; text-align: left;">
<tbody><tr><td align="left"><b><li><font color="red"></font></li></b></td>
<td align="left"><font color="red">You have exceeded the maximum number of sessions per hour allowed for the public queries. You may still access the public</font></td>
</tr>
<tr><td><font color="red"><li style="list-style: none;"></li></font></td>
<td align="left"><font color="red">queries by waiting an hour and trying your query again. The RRC public queries are provided to facilitate online research and are not intended to be accessed by automated tools or scripts. For questions or concerns please contact the RRC HelpDesk at helpdesk@rrc.state.tx.us or 512-463-7229</font></td>
</tr>
</tbody></table>
<p>....more html...</p>
</body></html>