Jython ValueError: chr () arg вне диапазона (256) - PullRequest
0 голосов
/ 09 декабря 2018

Я использую Jython (jython2.7.0) для отправки строкового значения из Java-программы в метод Python, а затем возвращаю значение в Java-программу, но я получаю эту ошибку.ValueError: chr() arg not in range(256) Знаете ли вы, в чем причина проблемы и как я могу ее решить ??

Exception in thread "main" Traceback (most recent call last):
  File "PageRanking.py", line 9, in <module>
    from bs4 import BeautifulSoup  
  File "C:\jython2.7.0\Lib\bs4\__init__.py", line 35, in <module>
    from .builder import builder_registry, ParserRejectedMarkup
  File "C:\jython2.7.0\Lib\bs4\builder\__init__.py", line 7, in <module>
    from bs4.element import (
  File "C:\jython2.7.0\Lib\bs4\element.py", line 10, in <module>
    from bs4.dammit import EntitySubstitution
  File "C:\jython2.7.0\Lib\bs4\dammit.py", line 14, in <module>
    from html.entities import codepoint2name
  File "C:\jython2.7.0\Lib\html\__init__.py", line 6, in <module>
    from html.entities import html5 as _html5
  File "C:\jython2.7.0\Lib\html\entities.py", line 2507, in <module>
    entitydefs[name] = chr(codepoint)

Это мой код Python

from __future__ import with_statement

from bs4 import BeautifulSoup  
    import requests

def pageRank(link):
    url = "https://checkpagerank.net/"

payload = {'name':link} 
r = requests.post(url, payload)
with open("requests_results.html", "wb") as f:
    f.write(r.content)

with open(r'requests_results.html', "r", encoding='utf-8') as f:
    text= f.read()


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

results = soup.find_all('h2')


SResult = results[1]

first= SResult.contents[0]
rankerName = first.find('b').text

second= SResult.contents[2]
rankervalue = second.find('b').text

x = rankervalue[:1]
x = int(x)
x= x*100/10

return x
...