나는 웹 스크레이퍼에서 일하고 있습니다. 다음 텍스트는이 질문 끝에 주어진 코드의 결과를 보여줍니다.이 코드는 페이지에서 모든 href의 값을 가져옵니다.
나는 단지 docid=
index.php? pageid = a45475a11ec72b843d74959b60fd7bd64556e8988583f
#
summary_of_documents.php
index.php? pageid = a45475a11ec72b843d74959b60fd7bd64579b861c1d7b
#
index.php? pageid = a45475a11ec72b843d74959b60fd7bd64579e0509c7f0 & apform = 사법부
decisions.php? doctype = 의사 결정 / 서명 된 해결 & docid = 1263778435388003271 # sam
decisions.php? doctype = 의사 결정 / 서명 된 해결 & docid = 12637789021669321156 # sam
? doctype = 결정 / 서명 된 해결 및 연도 = 1986 & 월 = 1 월 # 머리
? doctype = 결정 / 서명 된 해결 및 연도 = 1986 & 월 = 2 월 # 머리
코드는 다음과 같습니다.
string url = urlTextBox.Text;
string sourceCode = Extractor.getSourceCode(url);
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(sourceCode);
List<string> links = new List<string>();
if (links != null)
{
foreach (HtmlAgilityPack.HtmlNode nd in doc.DocumentNode.SelectNodes("//a[@href]"))
{
links.Add(nd.Attributes["href"].Value);
}
}
else
{
MessageBox.Show("No Links Found");
}
if (links != null)
{
foreach (string str in links)
{
richTextBox9.Text += str + "\n";
}
}
else
{
MessageBox.Show("No Link Values Found");
}
어떻게해야합니까?
왜 이것을 바꿀 뿐이 아닌가?
links.Add(nd.Attributes["href"].Value);
이걸로 :
if (nd.Attributes["href"].Value.Contains("docid="))
links.Add(nd.Attributes["href"].Value);