私は一般的なウェブショップのスクレーパーに取り組んでおり、奇妙な問題に遭遇しました。実際、ウェブページにリストされているすべての製品の正しい URL が必要でした。ほとんどの場合、これらの製品の href は相対的です。
新しい Uri メソッドを使用して完全な製品 URL を作成しています。
new Uri (base, href)
//this actually decide to add "/" before product href
href = x.ProductHref.IsUrlAbsolute() ? x.ProductHref : ((x.ProductHref.StartsWith("/") || (x.ProductHref.StartsWith("."))) ? x.ProductHref : "/" + x.ProductHref)
失敗した結果:これを修正する方法
Base URL: "www.bebitalia.it/Products/ProductList_it.html#filter&.CHAISE_LONGUE"
Product href: Product-landscape-chaise_longue_118_it.html
Result : http://www.bebitalia.it/Product-landscape-chaise_longue_118_it.html ==> Status Wrong
Expected: http://www.bebitalia.it/Products/Product-landscape-chaise_longue_118_it.html
私はそれを修正しようとしましたが、他の人には機能しません:)。ジェネリックにしたい。解決策を提案してください。AM I は正しい方向に進んでいるか、より良いアプローチが必要です。