在使用servlet的页面上使用requests.get()



我正试图使用Python中的请求库和BeautifulSoup从下面的网页中抓取数据。不幸的是,网站似乎使用servlet来检索数据,我不太确定如何处理

我已经尝试过直接从结果页面进行查询:

http://a810-bisweb.nyc.gov/bisweb/PropertyProfileOverviewServlet?bin=1014398&go4=+GO+&requestid=0
html = requests.get(url)
soup = BeautifulSoup(html.text, 'html')

同时从搜索页面查询:

url = 'http://a810-bisweb.nyc.gov/bisweb/bispi00.jsp'
html = requests.get(url, params={'bin':1014398})
soup = BeautifulSoup(html.text, 'html')

两者都以请求超时结束,可能是因为我没有正确格式化请求。有没有一种方法可以成功地从结果页面中捕获html?

尝试使用selenium:

from bs4 import BeautifulSoup
from selenium import webdriver
import time
url = 'http://a810-bisweb.nyc.gov/bisweb/PropertyProfileOverviewServlet?bin=1014398&go4=+GO+&requestid=0'
driver = webdriver.Chrome()
driver.get(url)
time.sleep(3)
soup = BeautifulSoup(driver.page_source, 'html5lib')
driver.close()

最新更新