我创建了一个virtualenv(我把它命名为scrape),我激活了它,并安装了包和beautifulsoup4。我试图使崇高的文本3工作(即显示建设结果)在一个虚拟。我创建了一个新的构建系统:
{
"cmd": ["C:/Users//User1/Desktop/scrape/Scripts/python.exe", "-u","$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
然后我运行以下代码(我知道Betfair有一个API,但这里不是重点):
^{pr2}$当我在Powershell和virualenv激活的情况下运行上面的代码时,我得到的是“200”,然后是所有的html数据(即ti应该是这样的)。当我在sublime文本中运行时,在buildresults面板中只得到“200”,没有任何html数据。我得到“200”意味着我的构建系统工作正常,但是为什么没有显示html结果呢?请注意,我没有得到任何错误。在
现在,如果我将url从https://betfair.com更改为https://ubet.com.cy/sports(其中包含一些希腊字符),那么如果我在Powershell中这样做,一切都正常(即我得到的是“200”加上html数据)。在
import requests
from bs4 import BeautifulSoup
url = requests.get("https://ubet.com.cy/sports")
print(url.status_code)
bs_4 = BeautifulSoup(url.text, "html.parser")
print(bs_4.prettify())
但是,如果我在崇高的文本中这样做,我得到的是“200”加上以下错误:
File "C:\Users\User1\Desktop\scrape\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\x93' in position 6074: character maps to <undefined>
这里是19号线:
17class IncrementalEncoder(codecs.IncrementalEncoder):
18 def encode(self, input, final=False):
19 return codecs.charmap_encode(input,self.errors,encoding_table)[0]
一般来说,我要寻找的是一种解决方案,使崇高文本的工作方式类似于在Powershell中运行python(看起来每次我都会遇到一个新的错误)。你有什么可以帮我的吗。在
非常感谢。在
这确实是一个崇高的具体文本问题。Sublime Text有一个^{} dictionary ,它将在执行Python之前更新环境变量。在
转到工具->构建系统->新建生成系统,并将^{} 设置为
utf8
:更多信息请访问:
相关问题 更多 >
编程相关推荐