Skip to content

Commit

Permalink
<em>태그 사용으로 페이지수 잘못세던 문제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
skygarlics committed Sep 27, 2018
1 parent c42f7d2 commit b1344f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DCfinder_GUI/DCfinder_GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.3.0.%2a</ApplicationVersion>
<ApplicationVersion>1.3.1.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down
13 changes: 3 additions & 10 deletions DCfinder_GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Library;
using static Library.DCfinder;
using System.Threading;
using System.Windows.Media.Animation;
using HtmlAgilityPack;
Expand Down Expand Up @@ -150,7 +141,9 @@ private async void SearchGallery(CancellationToken token)
{
search_query += "&exception_mode=recommend";
}
string board_url = dcfinder.gall_base_url + "/board/lists/?id=" + gallery_id;
// url encode

string board_url = dcfinder.gall_base_url + "/board/lists?id=" + gallery_id;
string request_url = board_url + String.Format(search_query, 1, search_pos, search_type, keyword);

// get first page
Expand Down
13 changes: 10 additions & 3 deletions Library/DCfinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Threading;
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Net.Http;

namespace Library
{
Expand Down Expand Up @@ -45,7 +46,7 @@ public async Task<uint> GetSearchPosAsync(string gallery_id, string keyword, str
{
HtmlNodeCollection links;

string board_url = gall_base_url + "/board/lists/?id=" + gallery_id;
string board_url = gall_base_url + "/board/lists?id=" + gallery_id;

string search_query = String.Format("&s_type={0}&s_keyword={1}", search_type, keyword);
string resp = await RequestPageAsync(board_url + search_query);
Expand Down Expand Up @@ -98,7 +99,7 @@ public async Task<ArticleCollection> CrawlSearchAsync(string gallery_id, string
{
search_query += "&exception_mode=recommend";
}
string board_url = gall_base_url + "/board/lists/?id=" + gallery_id;
string board_url = gall_base_url + "/board/lists?id=" + gallery_id;

// get page length of this search
string request_url = board_url + String.Format(search_query, 1, search_pos, search_type, keyword);
Expand Down Expand Up @@ -174,7 +175,9 @@ public string RequestPage(string url, string data)

public async Task<string> RequestPageAsync(string url)
{
url = System.Uri.EscapeUriString(url);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

// WebProxy proxy = new WebProxy("127.0.0.1:8080");
// req.Proxy = proxy;

Expand Down Expand Up @@ -239,7 +242,6 @@ public async Task<ArticleCollection> GetArticlesAsync(string url)
#endregion

#region CountPages
private static Regex rLink = new Regex("<a");

public int GetLastPage(HtmlNode page_btns)
{
Expand All @@ -252,6 +254,11 @@ public int GetLastPage(HtmlNode page_btns)
public int CountPages(HtmlNode page_btns)
{
int cnt = 0;
// <em> tag is current page
var curr = page_btns.SelectSingleNode("./em");
if (curr != null)
cnt++;

var links = page_btns.SelectNodes("./a");
foreach (var link in links)
{
Expand Down

0 comments on commit b1344f1

Please sign in to comment.