Skip to content

Instantly share code, notes, and snippets.

@osya
Last active November 26, 2015 07:28
Show Gist options
  • Save osya/2344e19ae196f372dfa3 to your computer and use it in GitHub Desktop.
Save osya/2344e19ae196f372dfa3 to your computer and use it in GitHub Desktop.
POST-request for filter for torgi.gov.ru #HtmlAgilityPack #CSharp
//Сделать POST-запрос для фильтра по дате
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(page_content);
HtmlNode node = doc.DocumentNode.SelectSingleNode(".//*[@id='lot_search']/../@onclick");
string id_s = node.Attributes["onclick"].Value;
var pat = @"id(..)";
var id = Regex.Matches(id_s, pat)[0].Groups[1].Value;
var date_filter_body = String.Format("id{0}_hf_0=&extended%3AbidOrganization%3AbidOrganizationName=&extended%3AbidOrganization%3AbidOrganizationLocation=&extended%3AbidOrganization%3AbidOrganizationInn=&extended%3AbidOrganization%3AbidOrganizationKinds%3AmultiSelectText=&extended%3AbidOrganization%3AbidOrganization=&extended%3AbidExtended%3AbidNumber=&extended%3AbidExtended%3AbidStatusId=&extended%3AbidNumberExtended%3AbidFormId=&extended%3AbidNumberExtended%3AdetailComplaintType=&extended%3AbidNumberExtended%3AexpireDateFrom=&extended%3AbidNumberExtended%3AexpireDateTo=&extended%3AbidNumberExtended%3ApublishDateFrom=&extended%3AbidNumberExtended%3ApublishDateTo=&extended%3AbidNumberExtended%3AlastChangeDateFrom=01.09.2014&extended%3AbidNumberExtended%3AlastChangeDateTo=30.09.2014&extended%3ApropertyTypes%3AmultiSelectText=&extended%3AdescriptionLot=&extended%3AlocationKladr=&extended%3AkladrIdStr=&extended%3AareaMeters%3AstringAreaMetersFrom=&extended%3AareaMeters%3AstringAreaMetersTo=&extended%3AcurrencyId=&extended%3AsubrentType=&extended%3AburdenType=&extended%3AstringPricePerMonthFrom=&extended%3AstringPricePerMonthTo=&extended%3ApropertyExtended%3AstringPricePerYearFrom=&extended%3ApropertyExtended%3AstringPricePerYearTo=&extended%3ApropertyExtended%3AstringDealFeeFrom=&extended%3ApropertyExtended%3AstringDealFeeTo=&extended%3ApropertyExtended%3AstringRentFrom=&extended%3ApropertyExtended%3AstringRentTo=&search_panel%3AbuttonsPanel%3Asearch=1", id);
var search_url = "http://torgi.gov.ru/?wicket:interface=:0:search_panel:buttonsPanel:search::IActivePageBehaviorListener:0:&wicket:ignoreIfNotActive=true";
webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
page_content = webClient.UploadString(new Uri(search_url), date_filter_body);
//Получить ActiveID
doc.LoadHtml(page_content);
node = doc.DocumentNode.SelectSingleNode(".//*[contains(concat(\" \", normalize-space(@class), \" \"), \"navigation\")]/td/div/a[contains(@onclick,\"next\")]/@id");
var ActiveId = node.Attributes["id"].Value;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment