Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
change4weixin
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shenjinzhu
change4weixin
Commits
d7887322
Commit
d7887322
authored
May 04, 2018
by
admin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
转链接增加重定向
parent
38c6dcd6
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
6 deletions
+22
-6
src/main/java/com/zhiwei/chendong/ExcelReadAndWrite.java
+19
-2
src/main/java/com/zhiwei/finance/PushFinanceByTime.java
+1
-1
src/main/java/com/zhiwei/util/ExcelUtil.java
+0
-1
src/main/resources/datasource.properties
+1
-1
target/classes/datasource.properties
+1
-1
No files found.
src/main/java/com/zhiwei/chendong/ExcelReadAndWrite.java
View file @
d7887322
...
@@ -8,7 +8,10 @@ import java.io.IOException;
...
@@ -8,7 +8,10 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.net.HttpURLConnection
;
import
java.net.Socket
;
import
java.net.Socket
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Calendar
;
...
@@ -528,7 +531,7 @@ public class ExcelReadAndWrite {
...
@@ -528,7 +531,7 @@ public class ExcelReadAndWrite {
continue
;
continue
;
}
}
}
}
System
.
out
.
println
(
"list:"
+
list
.
size
());
System
.
out
.
println
(
"list:"
+
list
.
size
());
System
.
out
.
println
(
urls
.
size
());
System
.
out
.
println
(
urls
.
size
());
m
.
insert
(
urls
);
// 存储
m
.
insert
(
urls
);
// 存储
Thread
.
sleep
(
1000
*
80
);
Thread
.
sleep
(
1000
*
80
);
...
@@ -553,7 +556,7 @@ public class ExcelReadAndWrite {
...
@@ -553,7 +556,7 @@ public class ExcelReadAndWrite {
if
(
null
!=
w
.
getUrl
()
&&
w
.
getUrl
().
startsWith
(
"https://mp.weixin.qq.com/s"
)
if
(
null
!=
w
.
getUrl
()
&&
w
.
getUrl
().
startsWith
(
"https://mp.weixin.qq.com/s"
)
||
w
.
getUrl
().
startsWith
(
"http://mp.weixin.qq.com/s"
))
{
||
w
.
getUrl
().
startsWith
(
"http://mp.weixin.qq.com/s"
))
{
if
(
map
.
get
(
w
.
getUrl
())
!=
null
)
{
if
(
map
.
get
(
w
.
getUrl
())
!=
null
)
{
w
.
setGetUrl
(
map
.
get
(
w
.
getUrl
(
)));
w
.
setGetUrl
(
urlRedirect
(
map
.
get
(
w
.
getUrl
()
)));
}
}
}
else
{
}
else
{
if
(
w
.
getUrl
()
==
null
)
{
if
(
w
.
getUrl
()
==
null
)
{
...
@@ -636,4 +639,18 @@ public class ExcelReadAndWrite {
...
@@ -636,4 +639,18 @@ public class ExcelReadAndWrite {
return
list
;
return
list
;
}
}
public
static
String
urlRedirect
(
String
url
)
{
String
result
=
null
;
try
{
URL
ul
=
new
URL
(
url
);
URLConnection
con
=
ul
.
openConnection
();
con
.
setRequestProperty
(
"Host"
,
"mp.weixin.qq.com"
);
con
.
setRequestProperty
(
"User-Agent"
,
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501 NetType/WIFI WindowsWechat QBCore/3.43.691.400 QQBrowser/9.0.2524.400"
);
result
=
con
.
getHeaderField
(
"Location"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
return
(
result
==
null
||
result
.
equals
(
""
))
?
url
:
result
;
}
}
}
src/main/java/com/zhiwei/finance/PushFinanceByTime.java
View file @
d7887322
...
@@ -20,7 +20,7 @@ import com.zw.entity.NewsResult;
...
@@ -20,7 +20,7 @@ import com.zw.entity.NewsResult;
import
sendmail.SendMailUtil
;
import
sendmail.SendMailUtil
;
@Component
//
@Component
public
class
PushFinanceByTime
extends
Thread
{
public
class
PushFinanceByTime
extends
Thread
{
private
static
final
Log
log
=
LogFactory
.
getLog
(
PushFinanceByTime
.
class
);
private
static
final
Log
log
=
LogFactory
.
getLog
(
PushFinanceByTime
.
class
);
...
...
src/main/java/com/zhiwei/util/ExcelUtil.java
View file @
d7887322
...
@@ -64,7 +64,6 @@ public class ExcelUtil {
...
@@ -64,7 +64,6 @@ public class ExcelUtil {
if
(!
tempFile
.
exists
())
{
if
(!
tempFile
.
exists
())
{
tempFile
.
createNewFile
();
tempFile
.
createNewFile
();
}
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
WritableWorkbook
workbook
=
Workbook
.
createWorkbook
(
tempFile
);
WritableWorkbook
workbook
=
Workbook
.
createWorkbook
(
tempFile
);
WritableSheet
sheet
=
workbook
.
createSheet
(
"table1"
,
0
);
WritableSheet
sheet
=
workbook
.
createSheet
(
"table1"
,
0
);
// 一些临时变量,用于写到excel中
// 一些临时变量,用于写到excel中
...
...
src/main/resources/datasource.properties
View file @
d7887322
basefile
=
/home/nbzhiwei/upload/
basefile
=
/home/nbzhiwei/upload/
#basefile=C:/Users/
Administrator/Desktop/news222.xls
#basefile=C:/Users/
admin/Desktop/
timefileUrl
=
/home/nbzhiwei/upload
timefileUrl
=
/home/nbzhiwei/upload
#timefileUrl=C:/Users/admin/Desktop
#timefileUrl=C:/Users/admin/Desktop
#host=106.14.249.240
#host=106.14.249.240
...
...
target/classes/datasource.properties
View file @
d7887322
basefile
=
/home/nbzhiwei/upload/
basefile
=
/home/nbzhiwei/upload/
#basefile=C:/Users/
Administrator/Desktop/news222.xls
#basefile=C:/Users/
admin/Desktop/
timefileUrl
=
/home/nbzhiwei/upload
timefileUrl
=
/home/nbzhiwei/upload
#timefileUrl=C:/Users/admin/Desktop
#timefileUrl=C:/Users/admin/Desktop
#host=106.14.249.240
#host=106.14.249.240
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment