<p>似乎此页面检查了<code>User-Agent</code>标题</p>
<p>它甚至可以在不完整的<code>"User-Agent": "Mozilla/5.0"</code>中工作</p>
<p><strong>顺便说一句:</strong>此表具有不同的ID:<code>'id': 'tablepress-342'</code></p>
<hr/>
<pre><code>import requests
from bs4 import BeautifulSoup
url = 'https://www.playnj.com/atlantic-city/revenue/'
r = requests.get(url, headers={"User-Agent": "Mozilla/5.0"})
print(r.status_code)
soup = BeautifulSoup(r.text, "html.parser")
october_table = soup.find('table', {'id': 'tablepress-342'})
#print(october_table)
for row in october_table.find_all('tr'):
for item in row.find_all('td'):
print(item.text)
print(' -')
</code></pre>
<p>结果</p>
<pre><code>200
-
Bally's
$3,799,907
$180,229
$9,107,610
$13,087,746
-
Borgata
$14,709,145
$1,060,246
$35,731,777
$51,501,168
-
Caesars
$7,097,502
$ -
$14,689,045
$21,786,547
-
Golden Nugget
$3,311,223
$84,387
$11,356,285
$14,751,895
-
Hard Rock
$7,849,617
$ -
$16,619,183
$24,468,800
-
Harrah's
$4,507,262
$205,921
$19,372,672
$24,085,855
-
Ocean Resort
$5,116,397
$65,276
$13,245,998
$18,427,671
-
Resorts
$2,257,149
$ -
$9,859,813
$12,116,962
-
Tropicana
$4,377,139
$152,876
$17,501,139
$22,031,154
-
Total
$53,025,341
$1,748,935
$147,483,522
$202,257,798
-
</code></pre>