所以我有这个代码:
List<PriceDetail> prices =
(from item in xmlDoc.Descendants(shop.DescendantXName)
select new PriceDetail
{
Price = GetPrice(item.Element(shop.PriceXPath).Value),
GameVersion = GetGameVersion(((IEnumerable)item.XPathEvaluate(shop.TitleXPath)).Cast<XAttribute>().First<XAttribute>().Value, item.Element(shop.PlatformXPath).Value),
Shop = shop,
Link = item.Element(shop.LinkXPath).Value,
InStock = InStock(item.Element(shop.InStockXPath).Value)
}).ToList<PriceDetail>();
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是这段代码:
((IEnumerable)item.XPathEvaluate(shop.TitleXPath)).Cast<XAttribute>().First<XAttribute>().Value
Run Code Online (Sandbox Code Playgroud)
有时来自XPathEvaluate的对象可能是XElement,然后转换不起作用.所以我需要的是一个适用于XAttribute和XElement的Cast.
有什么建议吗?
因此Django向我发送了以下信息:
[Django] ERROR: Invalid HTTP_HOST header: '<my server IP here>'.You may need to add u'<my server IP here>' to ALLOWED_HOSTS.
No stack trace available
Request repr() unavailable.
Run Code Online (Sandbox Code Playgroud)
问题是...您无法使用服务器IP访问我的网站,因为我只允许ALLOWED_HOST设置中的域。
所以我该怎么做?
编辑:我正在使用Nginx-> Gunicorn。有时仅会发生此错误,例如每周1-2次。