大家好,新Python用戶在這裏我在構建一個非常基本的頁面刮板時遇到了一個奇怪的錯誤。頁面刮板解析器錯誤?
我使用BeautifulSoup4來幫助我,當我執行我的代碼,我得到這個錯誤
「UserWarning:沒有解析器明確規定,所以我用最好的HTML解析器該系統(」 HTML .parser「)。這通常不是問題,但是如果您在另一個系統或不同虛擬環境中運行此代碼,它可能會使用不同的分析器並且行爲不同。位於文件C:/ Users/***/PycharmProjects/untitled1/s.py的第13行。要刪除此警告,請更改如下所示的代碼:「
BeautifulSoup([your markup])
to this:
BeautifulSoup([your markup], "html.parser")
markup_type=markup_type))
如果有人有任何幫助解決這個問題,我將不勝感激!
代碼遵循
import requests
from bs4 import BeautifulSoup
def trade_spider():
url = 'http://buckysroom.org/trade/search.php?page=' # Could add a + pls str(pagesomething) to add on to the url so that it would update
source_code = requests.get(url) #requests the data from the site
plain_text = source_code.text #imports all of the data gathered
soup = BeautifulSoup(plain_text) #This hold all of the data, and allows you to sort through all of the data, converts it
for link in soup.find_all('a', {'class' : 'item-name'}):
href = link.get('href')
print(href)
trade_spider()
的可能的複製[如何擺脫BeautifulSoup用戶警告?](http://stackoverflow.com/questions/33511544/how-to-get-rid-of-beautifulsoup-user-warning) –