【发布时间】:2021-02-17 15:59:21
【问题描述】:
我要做的就是从所有
from bs4 import BeautifulSoup
import requests
for page_no in range(1, 3):
data = {
'filterToken': "",
'instrumentType': "EQUITY",
'maxResultsPerPage': 10,
'pageNumber': page_no
}
page = requests.post('https://www.nyse.com/api/quotes/filter', data=data)
soup = BeautifulSoup(page.text, 'html.parser')
print('PAGE', page_no)
for name in soup.findAll('td'):
print(''.join(name.findAll(text=True)))
我没有收到任何错误,它只打印页码。我知道已经有几个 find_all 问题,但似乎都没有改变结果,也许我的“请求”是错误的?非常感谢任何帮助。
谢谢
【问题讨论】:
-
您是否尝试过打印页面以查看它的外观?或者通过
'<td' in page确保至少有一个“td”? -
检查你的汤 ->
HTTP Status 415 – Unsupported Media Type -- The origin server is refusing to service the request because the payload is in a format not supported by this method on the target resource并修复你的有效载荷问题。 -
@HedgeHog 好的,我正在调查它,会回复解决方案。谢谢
标签: python beautifulsoup findall