【发布时间】:2019-12-19 06:59:56
【问题描述】:
我正在尝试从website 获取数据。但在变量汤中没有获得任何字段的信息,如姓名、业务性质、电话、电子邮件等。我应该在下面的代码中添加什么来获得这些数据?
import requests
import pandas as pd
from bs4 import BeautifulSoup
page = "http://www.pmas.sg/page/members-directory"
pages = requests.get(page)
soup = BeautifulSoup(pages.content, 'html.parser')
print(soup)
我使用上面的代码得到的输出是:-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>WebKnight Application Firewall Alert</title>
<meta content="NOINDEX" name="ROBOTS"/>
</head>
<body bgcolor="#ffffff" link="#FF3300" text="#000000" vlink="#FF3300">
<table cellpadding="3" cellspacing="5" width="410">
<tr>
<td align="left">
<font face="Verdana,Arial,Helvetica" size="2">
<font size="3"><b>WebKnight Application Firewall Alert</b></font><br/><br/><br/>
Your request triggered an alert! If you feel that you have received this page in error, please contact the administrator of this web site.
<br/>
<hr/>
<br/><b>What is WebKnight?</b><br/>
AQTRONIX WebKnight is an application firewall for web servers and is released under the GNU General Public License. It is an ISAPI filter for securing web servers by blocking certain requests. If an alert is triggered WebKnight will take over and protect the web server.<br/><br/>
<hr/>
<br/>For more information on WebKnight: <a href="http://www.aqtronix.com/webknight/">http://www.aqtronix.com/WebKnight/</a><br/><br/>
<b><font color="#FF3300">AQTRONIX</font> WebKnight</b></font>
</td>
</tr>
</table>
</body>
</html>
【问题讨论】:
-
这是关于标题的。因为实际上你得到了
999的响应代码,所以你只需要user-agent。在下面查看我的答案
标签: python-3.x web-scraping beautifulsoup