Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
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
方斌
51business
Commits
e19487f6
Commit
e19487f6
authored
Apr 17, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tool fix
parent
9dd2a6b0
Pipeline
#6089
passed with stage
in 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
tool.js
app/controller/house/tool.js
+15
-7
No files found.
app/controller/house/tool.js
View file @
e19487f6
...
...
@@ -182,7 +182,7 @@ class ToolController extends Controller {
const
total_floor
=
input_params
.
total_floor
;
const
qfang_url_area
=
'https://hangzhou.qfang.com/fangjia/area'
;
const
qfang_url_chaxun
=
`https://hangzhou.qfang.com/fangjia/chaxun?userName=&gardenId=&gardenInternalID=
${
residential_id
}
&name=
${
residential_name
}
&area=
${
area
}
&floor=
${
floor
}
&totlaFloor=
${
total_floor
}
&directionStr=
${
direction_str
}
&buildingId=&building=&roomNoId=&roomNo=&subQueryType=quick`
;
console
.
info
(
qfang_url_chaxun
);
const
ret1
=
await
ctx
.
curl
(
qfang_url_area
,
{
method
:
'POST'
});
const
headers
=
ret1
.
headers
;
const
cookies
=
headers
[
'set-cookie'
];
...
...
@@ -194,26 +194,34 @@ class ToolController extends Controller {
const
user_agent_length
=
USER_AGENT
.
length
;
const
random
=
Math
.
floor
(
Math
.
random
()
*
user_agent_length
);
const
user_agent
=
USER_AGENT
[
random
];
console
.
info
(
ret1
);
const
ret2
=
await
ctx
.
curl
(
qfang_url_chaxun
,
{
headers
:
{
'host'
:
'hangzhou.qfang.com'
,
'origin'
:
'https://hangzhou.qfang.com'
,
'accept'
:
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8'
,
'accept-encoding'
:
'gzip, deflate, br'
,
'accept-language'
:
'zh-CN,zh;q=0.9,en;q=0.8'
,
'content-length'
:
227
,
'content-length'
:
'keep-alive'
,
'content-type'
:
'application/x-www-form-urlencoded'
,
'cache-control'
:
'max-age=0'
,
'cookie'
:
cookie
,
// 'referer': qfang_url_chaxun
,//不能加 一加就报错
'referer'
:
qfang_url_area
,
//不能加 一加就报错
'upgrade-insecure-requests'
:
1
,
'user-agent'
:
user_agent
,
'user-agent'
:
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36 LBBROWSER'
,
}
});
// ctx.success(ret2);
// return ;
ctx
.
logger
.
info
(
'qfang_url_chaxun_result: '
+
JSON
.
stringify
(
ret2
));
const
html
=
ret2
.
data
.
toString
(
'utf8'
);
console
.
info
(
html
);
if
(
ret2
.
status
!==
200
)
{
ctx
.
failed
(
'估算过程中出了点错,请稍后再试
!
'
);
ctx
.
failed
(
'估算过程中出了点错,请稍后再试
。
'
);
}
const
html
=
ret2
.
data
.
toString
(
'utf8'
);
//
const html = ret2.data.toString('utf8');
const
$
=
cheerio
.
load
(
html
);
const
average_price
=
$
(
'p.title-result'
).
text
();
// const total_price = $('#targetNum').html();
...
...
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