From 3d8be0924ec3f24f119391784f6412a4e4a62015 Mon Sep 17 00:00:00 2001 From: syo68k Date: Sat, 24 Apr 2010 03:51:27 +0000 Subject: [PATCH] =?utf8?q?pixiv/flickr=E3=81=AE=E3=83=97=E3=83=AC=E3=83=93?= =?utf8?q?=E3=83=A5=E3=83=BC=E3=81=8B=E3=82=89=E3=81=97=E3=81=B0=E3=82=89?= =?utf8?q?=E3=81=8F=E6=88=BB=E3=81=A3=E3=81=A6=E3=81=93=E3=81=AA=E3=81=8F?= =?utf8?q?=E3=81=AA=E3=82=8B=E5=A0=B4=E5=90=88=E3=81=8C=E3=81=82=E3=81=A3?= =?utf8?q?=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@182 e39ad16e-3079-482e-bb30-4b4d378143b6 --- Tween/Connection/HttpVarious.vb | 14 +++++++++++++- Tween/Tween.vb | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Tween/Connection/HttpVarious.vb b/Tween/Connection/HttpVarious.vb index 1753444c..51a8dd88 100644 --- a/Tween/Connection/HttpVarious.vb +++ b/Tween/Connection/HttpVarious.vb @@ -74,7 +74,7 @@ Public Class HttpVarious End Try End Function - Public Function GetData(ByVal Url As String, ByVal param As Dictionary(Of String, String), ByRef content As String) As Boolean + Public Overloads Function GetData(ByVal Url As String, ByVal param As Dictionary(Of String, String), ByRef content As String) As Boolean Dim req As HttpWebRequest = CreateRequest(GetMethod, New Uri(Url), param, False) Try Dim res As HttpStatusCode = Me.GetResponse(req, content, Nothing, False) @@ -85,6 +85,18 @@ Public Class HttpVarious End Try End Function + Public Overloads Function GetData(ByVal Url As String, ByVal param As Dictionary(Of String, String), ByRef content As String, ByVal timeout As Integer) As Boolean + Dim req As HttpWebRequest = CreateRequest(GetMethod, New Uri(Url), param, False) + req.Timeout = timeout + Try + Dim res As HttpStatusCode = Me.GetResponse(req, content, Nothing, False) + If res = HttpStatusCode.OK Then Return True + Return False + Catch ex As Exception + Return False + End Try + End Function + Public Function GetContent(ByVal method As String, ByVal Url As Uri, ByVal param As Dictionary(Of String, String), ByRef content As String, ByVal headerInfo As Dictionary(Of String, String), ByVal userAgent As String) As HttpStatusCode Dim req As HttpWebRequest = CreateRequest(method, Url, param, False) req.UserAgent = userAgent diff --git a/Tween/Tween.vb b/Tween/Tween.vb index 8e768b70..dff18737 100644 --- a/Tween/Tween.vb +++ b/Tween/Tween.vb @@ -7956,7 +7956,7 @@ RETRY: mc = Regex.Match(url, "^http://www\.pixiv\.net/(member_illust|index)\.php\?mode=(medium|big)&(amp;)?illust_id=(?[0-9]+)(&(amp;)?tag=(?.+))*$", RegexOptions.IgnoreCase) If Not mc.Groups("tag").Value = "R-18" AndAlso mc.Success Then Dim src As String = "" - If (New HttpVarious).GetData(Regex.Replace(mc.Groups(0).Value, "amp;", ""), Nothing, src) Then + If (New HttpVarious).GetData(Regex.Replace(mc.Groups(0).Value, "amp;", ""), Nothing, src, 5000) Then Dim _mc As Match = Regex.Match(src, mc.Result("http://img([0-9]+)\.pixiv\.net/img/.+/${illustId}_s\.([a-zA-Z]+)")) If _mc.Success Then imglist.Add(New KeyValuePair(Of String, String)(url, _mc.Value)) @@ -7972,7 +7972,7 @@ RETRY: mc = Regex.Match(url, "^http://www.flickr.com/", RegexOptions.IgnoreCase) If mc.Success Then Dim src As String = "" - If (New HttpVarious).GetData(url, Nothing, src) Then + If (New HttpVarious).GetData(url, Nothing, src, 5000) Then Dim _mc As MatchCollection = Regex.Matches(src, mc.Result("http://farm[0-9]+\.static\.flickr\.com/[0-9]+/.+\.([a-zA-Z]+)")) '二つ以上キャプチャした場合先頭の一つだけ 一つだけの場合はユーザーアイコンしか取れなかった If _mc.Count > 1 Then -- 2.11.0