Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python,BeautifulSoup4:选择多个属性分别等于多个值的元素_Python_Python 3.x_Beautifulsoup_Html Parsing - Fatal编程技术网

Python,BeautifulSoup4:选择多个属性分别等于多个值的元素

Python,BeautifulSoup4:选择多个属性分别等于多个值的元素,python,python-3.x,beautifulsoup,html-parsing,Python,Python 3.x,Beautifulsoup,Html Parsing,脚本运行没有错误,但没有找到任何东西。这一定是错误的,如果您使用Chrome打开页面(),右键单击,转到inspect->Network->Doc->Response,搜索,您将找到30个匹配结果。表标记名必须小写: import requests from bs4 import BeautifulSoup result=requests.get("http://news.scu.edu.cn/news2012/cdzx/I0201index_1.htm") result.encoding="G

脚本运行没有错误,但没有找到任何东西。这一定是错误的,如果您使用Chrome打开页面(),右键单击,转到inspect->Network->Doc->Response,搜索
,您将找到30个匹配结果。

标记名必须小写:

import requests
from bs4 import BeautifulSoup
result=requests.get("http://news.scu.edu.cn/news2012/cdzx/I0201index_1.htm")
result.encoding="GBK"
soup=BeautifulSoup(result.text,"html.parser")
soup=soup.find("TABLE",attrs={"cellspacing":"0","cellpadding": "0","width": 
"700","border":"0"})
print(soup)
以下是一份:

因为HTML标记和属性不区分大小写,所以所有三个HTML解析器都将标记和属性名称转换为小写。也就是说,将标记
转换为


谢谢,伙计!没错,我将“TABLE”改为“TABLE”,最后beautiful soup返回了一些有效信息。但似乎还有另一个问题:beautiful soup只返回30的第一个元素,你知道问题出在哪里吗?@bowen你有没有尝试过
find_all()
而不是
find()
?哦,对不起,我可以用谷歌搜索它。对不起,伙计,我一定是浪费了你的时间。非常感谢!!!
import requests
from bs4 import BeautifulSoup
result=requests.get("http://news.scu.edu.cn/news2012/cdzx/I0201index_1.htm")
result.encoding="GBK"
soup=BeautifulSoup(result.text,"html.parser")
soup=soup.find("TABLE",attrs={"cellspacing":"0","cellpadding": "0","width": 
"700","border":"0"})
print(soup)
soup = soup.find("table", ...)