Skip to content

Commit 7d09641

Browse files
committed
添加分页显示
1 parent ed39975 commit 7d09641

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

Diff for: public/javascripts/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ $(function() {
2828
type: 'GET',
2929
url: '/getGoogle',
3030
data: {
31-
keyword: encodeURI(value)
31+
keyword: value,
32+
start: artTemplate.start
3233
},
3334
success: function(data){
3435
$('#app').html(data.html)

Diff for: public/stylesheets/public.css

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ body{
4646
width: 100%;
4747
padding-right: 110px;
4848
border-radius: 6px;
49+
font-size: 18px;
4950
}
5051
.search-header .search-wrap .search-button{
5152
display: block;

Diff for: routes/index.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ var superagent = require('superagent');
44
var betaJSON = {
55
code: 200,
66
html: '<p style="font-size:40px;color:#333;">): 加载失败,我可能是个假服务器。</p>'
7-
87
}
9-
function getGoogleBase(keyword){
10-
return 'https://www.google.co.jp/search?q='+keyword+'&oq='+keyword+'&aqs=chrome..69i57j69i60l5.988j0j7&sourceid=chrome&ie=UTF-8'
8+
9+
const LocationUrl_Node = 'https://www.google.com.hk';
10+
11+
function getGoogleBase(keyword,start){
12+
return LocationUrl_Node+'/search?q='+keyword+'&oq='+keyword+'&start='+start+'&aqs=chrome..69i57j69i60l3j69i65l2.956j0j7&sourceid=chrome&ie=UTF-8'
1113
}
1214

1315
/* GET home page. */
@@ -16,15 +18,15 @@ router.get('/', function(req, res, next) {
1618
});
1719
router.get('/search', function(req, res, next) {
1820
res.render('index.art',{
19-
keyword: req.query.q || ''
21+
keyword: req.query.q || '',
22+
start: req.query.start || ''
2023
});
2124
});
2225

2326
router.get('/getGoogle', function(req, res, next) {
24-
2527
if(req.query.keyword){
2628

27-
superagent.get(getGoogleBase(req.query.keyword))
29+
superagent.get(getGoogleBase(req.query.keyword,req.query.start))
2830
.set('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8')
2931
.set('Accept-Language', 'zh-CN,zh;q=0.8,en;q=0.6')
3032
.set('User-Agent', req.headers['user-agent'] || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36')

Diff for: views/index.art

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
6161
<script type="text/javascript">
6262
window.artTemplate = {
63-
keyword: '{{keyword}}'
63+
keyword: '{{keyword}}',
64+
start: '{{start}}'
6465
}
6566
</script>
6667
<script type="text/javascript" src="/public/javascripts/index.js"></script>

0 commit comments

Comments
 (0)