이 웹 사이트의 결과를 구문 분석하려고했습니다. http://www.nokia.com/in-en/store-locator/?action=storeSearch&qt=madurai&tags=Nokia_Recycling_Point&country=IN
특히 div 클래스 '결과 래퍼'의 내용이 필요합니다. 즉, 모든 'h4', 'category'및 'description'범위 클래스입니다. 다음은 내가 도달 할 수있는 코드이며 나중에 특정 div를 구문 분석 할 수 없습니다. 해당 div 클래스의 모든 내용을 얻으려면 도움이 필요합니다.
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string htmlPage = "";
using (var client = new HttpClient())
{
try
{
htmlPage = await client.GetStringAsync("http://www.nokia.com/in-en/store-locator/?action=storeSearch&qt=madurai&tags=Nokia_Recycling_Point&country=IN");
}
catch (HttpRequestException exc) { }
}
HtmlDocument htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(htmlPage);
음, 시도해 볼 수 있습니다.
var resultWrapperDivs = htmlDocument.DocumentNode.SelectNodes("//div[@class='result-wrapper']");
foreach (var resultWrapperDiv in resultWrapperDivs)
{
// Do stuff with each div.
}
또한 특정 콘텐츠 / "html 태그"를 resultWrapperDiv
얻으려면 각각을 단독으로 가져 와서 자식 노드 ( resultWrapperDiv.SelectSingleNode
또는 resultWrapperDiv.SelectNodes
) 도 가져올 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다