![](/img/trans.png)
[英]Python Webscraping: Problems parsing chinese characters with beautiful soup/requests
[英]Beautiful Soup .find Chinese Characters
a_string = soup.find(text='圍')
soup.find_all('title', limit=1)
# [<title>The Dormouse's story</title>]
soup.find('title')
# <title>The Dormouse's story</title>
無論如何,我可以在使用beautifulsoup時使用漢字查找內容嗎?
嘗試了一段時間,似乎無法檢測到字符。 英文字符效果很好
我正在合作的網站來源
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="gbk" />
嘗試類似:
a_string = soup.find(text=re.compile(u'圍', re.U))
換句話說,應確保搜索到的字符串是unicode。 它可能不需要re.compile()
即可工作,但至少要確保您的中文字符串包含在u''
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.