久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

“findAll"之間的區別和“find_all"在美麗湯

Difference between quot;findAllquot; and quot;find_allquot; in BeautifulSoup(“findAll之間的區別和“find_all在美麗湯)
本文介紹了“findAll"之間的區別和“find_all"在美麗湯的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想用 Python 解析一個 HTML 文件,我使用的模塊是 BeautifulSoup.

I would like to parse an HTML file with Python, and the module I am using is BeautifulSoup.

據說函數find_allfindAll是一樣的.我都試過了,但我相信它們是不同的:

It is said that the function find_all is the same as findAll. I've tried both of them, but I believe they are different:

import urllib, urllib2, cookielib
from BeautifulSoup import *
site = "http://share.dmhy.org/topics/list?keyword=TARI+TARI+team_id%3A407"

rqstr = urllib2.Request(site)
rq = urllib2.urlopen(rqstr)
fchData = rq.read()

soup = BeautifulSoup(fchData)

t = soup.findAll('tr')

誰能告訴我區別?

推薦答案

BeautifulSoup 4 中,方法完全相同;混合大小寫版本(findAllfindAllNextnextSibling 等)都已重命名以符合 Python 風格指南,但 名稱仍然可以使移植更容易.完整列表請參見方法名稱.

In BeautifulSoup version 4, the methods are exactly the same; the mixed-case versions (findAll, findAllNext, nextSibling, etc.) have all been renamed to conform to the Python style guide, but the old names are still available to make porting easier. See Method Names for a full list.

在新代碼中,你應該使用小寫版本,所以find_all

In new code, you should use the lowercase versions, so find_all, etc.

然而,在您的示例中,您使用的是 BeautifulSoup version 3(自 2012 年 3 月起停止使用,如果您能提供幫助,請不要使用它),其中只有 findAll() 可用.未知屬性名稱(例如 .find_all,僅在 BeautifulSoup 4 中可用)被視為您正在搜索該名稱的標簽.您的文檔中沒有 <find_all> 標記,因此為此返回 None.

In your example however, you are using BeautifulSoup version 3 (discontinued since March 2012, don't use it if you can help it), where only findAll() is available. Unknown attribute names (such as .find_all, which only is available in BeautifulSoup 4) are treated as if you are searching for a tag by that name. There is no <find_all> tag in your document, so None is returned for that.

這篇關于“findAll"之間的區別和“find_all"在美麗湯的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Troubles while parsing with python very large xml file(使用 python 解析非常大的 xml 文件時出現問題)
Find all nodes by attribute in XML using Python 2(使用 Python 2 在 XML 中按屬性查找所有節點)
Python - How to parse xml response and store a elements value in a variable?(Python - 如何解析 xml 響應并將元素值存儲在變量中?)
How to get XML tag value in Python(如何在 Python 中獲取 XML 標記值)
How to correctly parse utf-8 xml with ElementTree?(如何使用 ElementTree 正確解析 utf-8 xml?)
Parse XML from URL into python object(將 XML 從 URL 解析為 python 對象)
主站蜘蛛池模板: 亚洲成人一二三 | 三级视频国产 | 久久精品| 国产精品久久国产精品 | 男人天堂国产 | 国产精品五区 | 久久在线视频 | 欧美视频在线一区 | 亚洲欧美国产精品久久 | 在线观看视频中文字幕 | 欧美在线一区二区三区 | 国产欧美在线播放 | 欧美日韩一区二区三区四区 | 久久aⅴ乱码一区二区三区 亚洲欧美综合精品另类天天更新 | 免费av一区二区三区 | 欧美中文字幕一区二区三区亚洲 | 成人性生交大片 | 国产福利在线 | 欧美日韩成人 | 欧美xxxⅹ性欧美大片 | 成人免费视频在线观看 | www.国产精品 | 精品国产乱码久久久久久88av | 日本三级黄视频 | 91n成人| 精品在线 | 男人午夜视频 | 久久久美女 | 欧美久久久网站 | 黄色av免费| 国产精品久久久久国产a级 欧美日本韩国一区二区 | 国产福利资源 | 一本色道久久综合亚洲精品高清 | 日韩三级一区 | 正在播放国产精品 | 精品一区二区三区不卡 | 亚洲精品www | 亚洲成人一级 | 视频一区二区三区中文字幕 | 天天干夜夜操视频 | www.玖玖玖 |