【问题标题】:how to scrape Bengali character properly with python如何用python正确刮取孟加拉语字符
【发布时间】:2021-11-26 14:46:51
【问题描述】:

我想用 python 正确地刮取孟加拉语字符。我已经尝试解码它,但它给了我一个错误,而我编码它给了我一些不可读的东西

from bs4 import BeautifulSoup


import requests

import urllib3

import requests

import pprint

import json

from requests.models import DecodeError
from urllib3.util.url import Url

content = []

# for i in range(1, 25):
url = 'https://sattacademy.com/job-solution/view?cat_id=1&sub_cat_id=893'

res= requests.get(url)

soup = BeautifulSoup(res.text, 'html.parser')

anchor = soup.findAll("a", attrs={"class": "nav-link"})


for ref in anchor:

   print(ref.text)

这是我的输出 -> enter image description here

但我想要这个 clearry.Thnx

【问题讨论】:

  • 你好,你能发一张ref.text值的图片吗?
  • @Hamed 我在我的输出链接中发送它请检查它thnx

标签: python web-scraping


【解决方案1】:

此链接可能会对您有所帮助。演示如何在 python 中打印 utf-8 字符。

Printing unicode number of chars in a string (Python)

【讨论】:

  • 它不起作用,因为我的字符串不是这种形式,它解码得不够好,这就是为什么它给了我这样的输出i.stack.imgur.com/HUUWJ.png
  • 在我的代码中实现它之后,它给了我一些十进制数"nav-link"}) for i in soup: print(repr(i), i)
  • 你在评论中输出的图片和有问题的图片是一样的吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-24
  • 2017-03-16
  • 2011-09-24
  • 1970-01-01
  • 2021-12-25
相关资源
最近更新 更多