Closed null-ed closed 4 years ago
这个问题已经考虑到了,自己注册一下 SelectableBuilder 处理就好
这个问题已经考虑到了,自己注册一下SelectableBuilder处理就好
可以举例具体如何使用吗?谢谢!
class MyDataParser : DataParser
{
public MyDataParser()
{
AddRequiredValidator("cnblogs\\.com");
AddFollowRequestQuerier(Selectors.XPath("."));
SelectableBuilder = context =>
{
var bytes = context.Response.Content.Data;
var text = bytes.ToText();
return new HtmlSelectable(text, null, true);
};
}
在DataParser类中的HandleAsync方法中,调用ReadAsString方法时默认编码为UTF-8,如果网页编码为GBK时,在DataParser的子类中实现Parse后,DataContext.Selectable为乱码,无法直接使用。